Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3282156
ArcanistCpplintLinter.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
1 KB
Referenced Files
None
Subscribers
None
ArcanistCpplintLinter.php
View Options
<?php
/**
* Uses Google's `cpplint.py` to check code.
*/
final
class
ArcanistCpplintLinter
extends
ArcanistExternalLinter
{
public
function
getLinterName
(
)
{
return
'C++ Google\'s Styleguide'
;
}
public
function
getLinterConfigurationName
(
)
{
return
'cpplint'
;
}
public
function
getDefaultBinary
(
)
{
return
'cpplint'
;
}
public
function
getInstallInstructions
(
)
{
return
pht
(
'Install cpplint.py using `%s`.'
,
'wget http://google-styleguide.googlecode.com'
.
'/svn/trunk/cpplint/cpplint.py'
)
;
}
protected
function
getDefaultMessageSeverity
(
$code
)
{
return
ArcanistLintSeverity
::
SEVERITY_WARNING
;
}
protected
function
parseLinterOutput
(
$path
,
$err
,
$stdout
,
$stderr
)
{
$lines
=
explode
(
"\n"
,
$stderr
)
;
$messages
=
array
(
)
;
foreach
(
$lines
as
$line
)
{
$line
=
trim
(
$line
)
;
$matches
=
null
;
$regex
=
'/^-:(\d+):\s*(.*)\s*\[(.*)\] \[(\d+)\]$/'
;
if
(
!
preg_match
(
$regex
,
$line
,
$matches
)
)
{
continue
;
}
foreach
(
$matches
as
$key
=>
$match
)
{
$matches
[
$key
]
=
trim
(
$match
)
;
}
$severity
=
$this
->
getLintMessageSeverity
(
$matches
[
3
]
)
;
$message
=
new
ArcanistLintMessage
(
)
;
$message
->
setPath
(
$path
)
;
$message
->
setLine
(
$matches
[
1
]
)
;
$message
->
setCode
(
$matches
[
3
]
)
;
$message
->
setName
(
$matches
[
3
]
)
;
$message
->
setDescription
(
$matches
[
2
]
)
;
$message
->
setSeverity
(
$severity
)
;
$messages
[
]
=
$message
;
}
return
$messages
;
}
protected
function
getLintCodeFromLinterConfigurationKey
(
$code
)
{
if
(
!
preg_match
(
'@^[a-z_]+/[a-z_]+$@'
,
$code
)
)
{
throw
new
Exception
(
pht
(
'Unrecognized lint message code "%s". Expected a valid cpplint '
.
'lint code like "%s" or "%s".'
,
$code
,
'build/include_order'
,
'whitespace/braces'
)
)
;
}
return
$code
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Mar 24, 05:42 (4 d, 4 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1139297
Default Alt Text
ArcanistCpplintLinter.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment