Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3493352
ArcanistCoffeeLintLinter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
ArcanistCoffeeLintLinter.php
View Options
<?php
final
class
ArcanistCoffeeLintLinter
extends
ArcanistExternalLinter
{
private
$config
;
public
function
getInfoName
(
)
{
return
'CoffeeLint'
;
}
public
function
getInfoURI
(
)
{
return
'http://www.coffeelint.org'
;
}
public
function
getInfoDescription
(
)
{
return
pht
(
'CoffeeLint is a style checker that helps keep CoffeeScript '
.
'code clean and consistent.'
)
;
}
public
function
getLinterName
(
)
{
return
'COFFEE'
;
}
public
function
getLinterConfigurationName
(
)
{
return
'coffeelint'
;
}
public
function
getDefaultBinary
(
)
{
return
'coffeelint'
;
}
public
function
getVersion
(
)
{
list
(
$stdout
)
=
execx
(
'%C --version'
,
$this
->
getExecutableCommand
(
)
)
;
$matches
=
array
(
)
;
if
(
preg_match
(
'/^(?P<version>\d+\.\d+\.\d+)$/'
,
$stdout
,
$matches
)
)
{
return
$matches
[
'version'
]
;
}
else
{
return
false
;
}
}
public
function
getInstallInstructions
(
)
{
return
pht
(
'Install CoffeeLint using `npm install -g coffeelint`.'
)
;
}
public
function
shouldExpectCommandErrors
(
)
{
return
true
;
}
public
function
supportsReadDataFromStdin
(
)
{
return
true
;
}
public
function
getReadDataFromStdinFilename
(
)
{
return
'--stdin'
;
}
protected
function
getMandatoryFlags
(
)
{
$options
=
array
(
'--reporter=checkstyle'
,
'--color=never'
,
'--quiet'
,
)
;
if
(
$this
->
config
)
{
$options
[
]
=
'--file='
.
$this
->
config
;
}
return
$options
;
}
public
function
getLinterConfigurationOptions
(
)
{
$options
=
array
(
'coffeelint.config'
=>
array
(
'type'
=>
'optional string'
,
'help'
=>
pht
(
'A custom configuration file.'
)
,
)
,
)
;
return
$options
+
parent
::
getLinterConfigurationOptions
(
)
;
}
public
function
setLinterConfigurationValue
(
$key
,
$value
)
{
switch
(
$key
)
{
case
'coffeelint.config'
:
$this
->
config
=
$value
;
return
;
}
return
parent
::
setLinterConfigurationValue
(
$key
,
$value
)
;
}
protected
function
parseLinterOutput
(
$path
,
$err
,
$stdout
,
$stderr
)
{
$report_dom
=
new
DOMDocument
(
)
;
$ok
=
@
$report_dom
->
loadXML
(
$stdout
)
;
if
(
!
$ok
)
{
return
false
;
}
$files
=
$report_dom
->
getElementsByTagName
(
'file'
)
;
$messages
=
array
(
)
;
foreach
(
$files
as
$file
)
{
foreach
(
$file
->
getElementsByTagName
(
'error'
)
as
$error
)
{
// Column number is not provided in the output.
// See https://github.com/clutchski/coffeelint/issues/87
$message
=
new
ArcanistLintMessage
(
)
;
$message
->
setPath
(
$path
)
;
$message
->
setLine
(
$error
->
getAttribute
(
'line'
)
)
;
$message
->
setCode
(
$this
->
getLinterName
(
)
)
;
$message
->
setDescription
(
preg_replace
(
'/; context: .*$/'
,
'.'
,
$error
->
getAttribute
(
'message'
)
)
)
;
switch
(
$error
->
getAttribute
(
'severity'
)
)
{
case
'warning'
:
$message
->
setSeverity
(
ArcanistLintSeverity
::
SEVERITY_WARNING
)
;
break
;
case
'error'
:
$message
->
setSeverity
(
ArcanistLintSeverity
::
SEVERITY_ERROR
)
;
break
;
default
:
$message
->
setSeverity
(
ArcanistLintSeverity
::
SEVERITY_ADVICE
)
;
break
;
}
$messages
[
]
=
$message
;
}
}
return
$messages
;
}
protected
function
getLintCodeFromLinterConfigurationKey
(
$code
)
{
// NOTE: We can't figure out which rule generated each message, so we
// can not customize severities.
throw
new
Exception
(
pht
(
"CoffeeLint does not currently support custom severity levels, "
.
"because rules can't be identified from messages in output."
)
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Apr 17, 06:40 (5 d, 1 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1287445
Default Alt Text
ArcanistCoffeeLintLinter.php (3 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment