Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22395491
ComprehensiveLintEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
ComprehensiveLintEngine.php
View Options
<?php
/**
* Basic lint engine which just applies several linters based on the file types.
*/
final
class
ComprehensiveLintEngine
extends
ArcanistLintEngine
{
public
function
buildLinters
()
{
$linters
=
array
();
$paths
=
$this
->
getPaths
();
foreach
(
$paths
as
$key
=>
$path
)
{
if
(
preg_match
(
'@^externals/@'
,
$path
))
{
// Third-party stuff lives in /externals/; don't run lint engines
// against it.
unset
(
$paths
[
$key
]);
}
}
$text_paths
=
preg_grep
(
'/
\.
(php|css|hpp|cpp|l|y|py|pl)$/'
,
$paths
);
$linters
[]
=
id
(
new
ArcanistGeneratedLinter
())->
setPaths
(
$text_paths
);
$linters
[]
=
id
(
new
ArcanistNoLintLinter
())->
setPaths
(
$text_paths
);
$linters
[]
=
id
(
new
ArcanistTextLinter
())->
setPaths
(
$text_paths
);
$linters
[]
=
id
(
new
ArcanistFilenameLinter
())->
setPaths
(
$paths
);
$linters
[]
=
id
(
new
ArcanistXHPASTLinter
())
->
setPaths
(
preg_grep
(
'/
\.
php$/'
,
$paths
));
$py_paths
=
preg_grep
(
'/
\.
py$/'
,
$paths
);
$linters
[]
=
id
(
new
ArcanistPyFlakesLinter
())->
setPaths
(
$py_paths
);
$linters
[]
=
id
(
new
ArcanistPEP8Linter
())
->
setFlags
(
$this
->
getPEP8WithTextOptions
())
->
setPaths
(
$py_paths
);
$linters
[]
=
id
(
new
ArcanistRubyLinter
())
->
setPaths
(
preg_grep
(
'/
\.
rb$/'
,
$paths
));
$linters
[]
=
id
(
new
ArcanistJSHintLinter
())
->
setPaths
(
preg_grep
(
'/
\.
js$/'
,
$paths
));
return
$linters
;
}
protected
function
getPEP8WithTextOptions
()
{
// E101 is subset of TXT2 (Tab Literal).
// E501 is same as TXT3 (Line Too Long).
// W291 is same as TXT6 (Trailing Whitespace).
// W292 is same as TXT4 (File Does Not End in Newline).
// W293 is same as TXT6 (Trailing Whitespace).
return
array
(
'--ignore=E101,E501,W291,W292,W293'
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 27, 16:26 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1221296
Default Alt Text
ComprehensiveLintEngine.php (1 KB)
Attached To
Mode
R118 Arcanist - fork
Attached
Detach File
Event Timeline