Skip to content
This repository was archived by the owner on Oct 5, 2022. It is now read-only.

Commit 1e13ee1

Browse files
committed
Coffeelint settings and fixes
1 parent 430abf3 commit 1e13ee1

8 files changed

+91
-49
lines changed

coffeelint.json

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"arrow_spacing": {
3+
"name": "arrow_spacing",
4+
"level": "error"
5+
},
6+
"ensure_comprehensions": {
7+
"name": "ensure_comprehensions",
8+
"level": "error"
9+
},
10+
"max_line_length": {
11+
"name": "max_line_length",
12+
"value": 120,
13+
"level": "error",
14+
"limitComments": true
15+
},
16+
"indentation": {
17+
"name": "indentation",
18+
"value": 2,
19+
"level": "error"
20+
},
21+
"no_empty_param_list": {
22+
"name": "no_empty_param_list",
23+
"level": "error"
24+
},
25+
"cyclomatic_complexity": {
26+
"name": "cyclomatic_complexity",
27+
"value": 22,
28+
"level": "error"
29+
},
30+
"no_unnecessary_fat_arrows": {
31+
"name": "no_unnecessary_fat_arrows",
32+
"level": "error"
33+
},
34+
"space_operators": {
35+
"name": "space_operators",
36+
"level": "error"
37+
},
38+
"spacing_after_comma": {
39+
"name": "spacing_after_comma",
40+
"level": "error"
41+
}
42+
}

lib/editor-control.coffee

+20-20
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ ImportListView = require './import-list-view'
33

44
{bufferPositionFromMouseEvent} = require './utils'
55
{TooltipMessage} = require './tooltip-view'
6-
{Range,CompositeDisposable,Disposable} = require 'atom'
6+
{Range, CompositeDisposable, Disposable} = require 'atom'
77

88
class EditorControl
99
constructor: (@editor, @manager) ->
@@ -31,12 +31,12 @@ class EditorControl
3131
# buffer events for automatic check
3232
buffer = @editor.getBuffer()
3333
editorElement = atom.views.getView(@editor)
34-
@disposables.add buffer.onWillSave () ->
34+
@disposables.add buffer.onWillSave ->
3535
# TODO if uri was changed, then we have to remove all current markers
3636
if atom.config.get('ide-haskell.onSavePrettify')
3737
atom.commands.dispatch editorElement, 'ide-haskell:prettify-file'
3838

39-
@disposables.add buffer.onDidSave () ->
39+
@disposables.add buffer.onDidSave ->
4040
# TODO if uri was changed, then we have to remove all current markers
4141
if atom.config.get('ide-haskell.onSaveCheck')
4242
atom.commands.dispatch editorElement, 'ide-haskell:check-file'
@@ -56,7 +56,7 @@ class EditorControl
5656
@clearExprTypeTimeout()
5757
@exprTypeTimeout = setTimeout (=>
5858
(@showCheckResult e) or
59-
(@showExpressionType bufferPt, 'mouse', 'get'+action)
59+
(@showExpressionType bufferPt, 'mouse', 'get' + action)
6060
), atom.config.get('ide-haskell.expressionTypeInterval')
6161
@disposables.add @editorElement, 'mouseout', '.scroll-view', (e) =>
6262
action = atom.config.get('ide-haskell.onMouseHoverShow')
@@ -82,7 +82,7 @@ class EditorControl
8282
@editorElement = null
8383
@editor = null
8484
@lastMouseBufferPt = null
85-
@tooltipMarkers=null
85+
@tooltipMarkers = null
8686

8787
# helper function to hide tooltip and stop timeout
8888
clearExprTypeTimeout: ->
@@ -107,7 +107,7 @@ class EditorControl
107107
return unless uri is @editor.getURI()
108108

109109
# create a new marker
110-
range = new Range position, {row: position.row, column: position.column+1}
110+
range = new Range position, {row: position.row, column: position.column + 1}
111111
marker = @editor.markBufferRange range,
112112
type: 'check-result'
113113
severity: severity
@@ -119,7 +119,7 @@ class EditorControl
119119
@decorateMarker(m)
120120

121121
decorateMarker: (m) ->
122-
cls = 'ide-haskell-'+m.getProperties().severity
122+
cls = 'ide-haskell-' + m.getProperties().severity
123123
@gutter.decorateMarker m, type: 'line-number', class: cls
124124
@editor.decorateMarker m, type: 'highlight', class: cls
125125
@editor.decorateMarker m, type: 'line', class: cls
@@ -153,10 +153,10 @@ class EditorControl
153153
@hideExpressionType()
154154
return
155155

156-
runPendingEvent = ({fun,crange}) =>
156+
runPendingEvent = ({fun, crange}) =>
157157
@showExpressionTypePendingEvent = null
158158
@showExpressionTypeRunning = true
159-
@manager.backend?[fun] @editor.getBuffer(), crange, ({range,type,info}) =>
159+
@manager.backend?[fun] @editor.getBuffer(), crange, ({range, type, info}) =>
160160
return unless @editor?
161161
if @showExpressionTypePendingEvent?
162162
runPendingEvent @showExpressionTypePendingEvent
@@ -177,7 +177,7 @@ class EditorControl
177177
unless type?
178178
@manager.backendWarning()
179179
return
180-
@markerBufferRange=range
180+
@markerBufferRange = range
181181
if mouseEvent or contextEvent
182182
tooltipMarker = @editor.markBufferPosition range.start
183183
else
@@ -200,7 +200,7 @@ class EditorControl
200200
runPendingEvent @showExpressionTypePendingEvent
201201

202202
hideExpressionType: ->
203-
@tooltipHighlightRange=null
203+
@tooltipHighlightRange = null
204204
@tooltipMarkers.dispose()
205205
@tooltipMarkers = new CompositeDisposable
206206

@@ -241,15 +241,15 @@ class EditorControl
241241
crange = @editor.getLastSelection().getBufferRange()
242242
else
243243
throw new Error "unknown event type #{eventType}"
244-
@manager.backend.getType @editor.getBuffer(), crange, ({range,type}) =>
244+
@manager.backend.getType @editor.getBuffer(), crange, ({range, type}) =>
245245
return unless @editor?
246246
n = @editor.indentationForBufferRow(range.start.row)
247-
indent = ' '.repeat n*@editor.getTabLength()
248-
@editor.scanInBufferRange /[\w'.]+/, range, ({matchText,stop}) =>
247+
indent = ' '.repeat n * @editor.getTabLength()
248+
@editor.scanInBufferRange /[\w'.]+/, range, ({matchText, stop}) =>
249249
symbol = matchText
250-
pos=[range.start.row,0]
251-
@editor.setTextInBufferRange [pos,pos],
252-
indent+symbol+" :: "+type+"\n"
250+
pos = [range.start.row, 0]
251+
@editor.setTextInBufferRange [pos, pos],
252+
indent + symbol + " :: " + type + "\n"
253253
stop()
254254

255255
insertImport: (eventType) ->
@@ -271,12 +271,12 @@ class EditorControl
271271
# "(\\s+as\\s+[\\w.']+)?(\\s+hiding)?"+
272272
# "(\\s+\\((.*)\\))")
273273
buffer = @editor.getBuffer()
274-
buffer.backwardsScan /^(\s*)import/, ({match,range}) =>
274+
buffer.backwardsScan /^(\s*)import/, ({match, range}) =>
275275
r = buffer.rangeForRow range.start.row
276-
@editor.setTextInBufferRange [r.end,r.end],
276+
@editor.setTextInBufferRange [r.end, r.end],
277277
"\n#{match[1]}import #{mod}"
278278

279-
closeTooltips: () ->
279+
closeTooltips: ->
280280
@hideExpressionType()
281281
@hideCheckResult()
282282

lib/ide-haskell.coffee

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{PluginManager} = require './plugin-manager'
2-
{TooltipMessage,TooltipElement} = require './tooltip-view'
2+
{TooltipMessage, TooltipElement} = require './tooltip-view'
33
{getCabalProjectDir} = require './utils'
44
{CompositeDisposable} = require 'atom'
55
BackendHelper = require 'atom-backend-helper'
@@ -117,8 +117,8 @@ module.exports = IdeHaskell =
117117
atom.menu.update()
118118

119119
setKB: (source, kbs) ->
120-
for o,c of kbs
121-
@watchKB o,source,c
120+
for o, c of kbs
121+
@watchKB o, source, c
122122

123123
setHotkeys: ->
124124
@setKB 'atom-workspace',
@@ -135,7 +135,7 @@ module.exports = IdeHaskell =
135135
CloseTooltip: 'ide-haskell:close-tooltip'
136136

137137
unsetHotkeys: ->
138-
d.dispose() for o,d of @hotkeys
138+
d.dispose() for o, d of @hotkeys
139139

140140
isActive: ->
141141
!!@pluginManager
@@ -174,7 +174,7 @@ module.exports = IdeHaskell =
174174
# if we did not activate (no cabal project),
175175
# set up an event to activate when a haskell file is opened
176176
if not @isActive()
177-
@disposables.add myself=atom.workspace.onDidOpen (event) =>
177+
@disposables.add myself = atom.workspace.onDidOpen (event) =>
178178
if not @isActive()
179179
item = event.item
180180
if item?.getGrammar?()?.scopeName == "source.haskell"
@@ -217,16 +217,16 @@ module.exports = IdeHaskell =
217217
@pluginManager.lintFile target.getModel()
218218
'ide-haskell:prettify-file': ({target}) =>
219219
@pluginManager.prettifyFile target.getModel()
220-
'ide-haskell:show-type': ({target,detail}) =>
220+
'ide-haskell:show-type': ({target, detail}) =>
221221
@pluginManager.controller(target.getModel()).showExpressionType null,
222-
getEventType(detail),'getType'
223-
'ide-haskell:show-info': ({target,detail}) =>
222+
getEventType(detail), 'getType'
223+
'ide-haskell:show-info': ({target, detail}) =>
224224
@pluginManager.controller(target.getModel()).showExpressionType null,
225-
getEventType(detail),'getInfo'
226-
'ide-haskell:insert-type': ({target,detail}) =>
225+
getEventType(detail), 'getInfo'
226+
'ide-haskell:insert-type': ({target, detail}) =>
227227
@pluginManager.controller(target.getModel())
228228
.insertType getEventType(detail)
229-
'ide-haskell:insert-import': ({target,detail}) =>
229+
'ide-haskell:insert-import': ({target, detail}) =>
230230
@pluginManager.controller(target.getModel())
231231
.insertImport getEventType(detail)
232232
'ide-haskell:close-tooltip': ({target}) =>
@@ -294,7 +294,7 @@ module.exports = IdeHaskell =
294294

295295
clearMenu: ->
296296
@menu.dispose()
297-
@menu=null
297+
@menu = null
298298
atom.menu.update()
299299

300300
consumeBackend_0_1_2: (service) ->

lib/import-list-view.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
module.exports=
55
class ImportListView extends SelectListView
6-
initialize: ({@onConfirmed,items}) ->
6+
initialize: ({@onConfirmed, items}) ->
77
super
88
@panel = atom.workspace.addModalPanel
99
item: this

lib/plugin-manager.coffee

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class PluginManager
1212
@disposables = new CompositeDisposable
1313
@controllers = new WeakMap
1414

15-
@disposables.add @emitter=new Emitter
15+
@disposables.add @emitter = new Emitter
1616

1717
@createOutputViewPanel(state)
1818
@subscribeEditorController()
@@ -45,23 +45,23 @@ class PluginManager
4545
@outputView?.toggle()
4646

4747
checkFile: (editor) ->
48-
@checkOrLint editor,@backend?.checkBuffer,['error', 'warning']
48+
@checkOrLint editor, @backend?.checkBuffer, ['error', 'warning']
4949

5050
lintFile: (editor) ->
51-
@checkOrLint editor,@backend?.lintBuffer,['lint']
51+
@checkOrLint editor, @backend?.lintBuffer, ['lint']
5252

5353
checkOrLint: (editor, func, types) =>
5454
return unless func?
5555
@outputView?.pendingCheck()
5656
func editor.getBuffer(), (res) =>
57-
@checkResults[t] = (res.filter ({severity}) -> severity==t) for t in types
57+
@checkResults[t] = (res.filter ({severity}) -> severity == t) for t in types
5858
@emitter.emit 'results-updated', {res: @checkResults, types}
5959

6060
onResultsUpdated: (callback) =>
6161
@emitter.on 'results-updated', callback
6262

6363
# File prettify
64-
prettifyFile: (editor, format='haskell') ->
64+
prettifyFile: (editor, format = 'haskell') ->
6565
[firstCursor, cursors...] = editor.getCursors().map (cursor) ->
6666
cursor.getBufferPosition()
6767
util = switch format
@@ -98,7 +98,7 @@ class PluginManager
9898
addController: (editor) ->
9999
unless @controllers.get(editor)?
100100
@controllers.set(editor, new EditorControl(editor, this))
101-
@disposables.add editor.onDidDestroy () =>
101+
@disposables.add editor.onDidDestroy =>
102102
@controllers.delete(editor) #deactivation is handled in EditorControl
103103

104104
removeController: (editor) ->

lib/tooltip-view.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ class TooltipMessage
55

66
class TooltipView extends HTMLElement
77
setMessage: (message) ->
8-
@inner.textContent=message.text
9-
$(this).fadeTo(0,1)
8+
@inner.textContent = message.text
9+
$(this).fadeTo(0, 1)
1010
this
1111

1212
createdCallback: ->
13-
@rootElement=this
14-
@inner=document.createElement('div')
13+
@rootElement = this
14+
@inner = document.createElement 'div'
1515
@appendChild @inner
1616

1717
destroy: ->

lib/util-cabal-format.coffee

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@ path = require 'path'
33
Temp = require 'temp'
44
FS = require 'fs'
55

6-
withTempFile = (contents,callback) ->
6+
withTempFile = (contents, callback) ->
77
Temp.open
88
prefix:'haskell-ghc-mod',
99
suffix:'.hs',
10-
(err,info) ->
10+
(err, info) ->
1111
if err
1212
console.log(err)
1313
return
14-
FS.writeSync info.fd,contents
14+
FS.writeSync info.fd, contents
1515
callback info.path, ->
1616
FS.close info.fd, -> FS.unlink info.path
1717

1818
# run cabal format
1919
prettify = (text, {onComplete, onFailure}) ->
2020
shpath = atom.config.get('ide-haskell.cabalPath')
2121

22-
withTempFile text, (path,close) ->
22+
withTempFile text, (path, close) ->
2323
proc = new BufferedProcess
2424
command: shpath
25-
args: ['format',path]
25+
args: ['format', path]
2626
exit: ->
2727
FS.readFile path, encoding: 'utf-8', (error, text) ->
2828
if error?

lib/util-stylish-haskell.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ path = require 'path'
55
# run stylish-haskell backend
66
prettify = (text, {onComplete, onFailure}) ->
77

8-
lines=[]
8+
lines = []
99

1010
shpath = atom.config.get('ide-haskell.stylishHaskellPath')
1111

0 commit comments

Comments
 (0)