Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F21401623
ArcanistLintJSONRenderer.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
ArcanistLintJSONRenderer.php
View Options
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Shows lint messages to the user.
*
* @group lint
*/
class
ArcanistLintJSONRenderer
{
const
LINES_OF_CONTEXT
=
3
;
public
function
renderLintResult
(
ArcanistLintResult
$result
)
{
$messages
=
$result
->
getMessages
();
$path
=
$result
->
getPath
();
$data
=
explode
(
"
\n
"
,
$result
->
getData
());
array_unshift
(
$data
,
''
);
// make the line numbers work as array indices
$output
=
array
(
$path
=>
array
());
foreach
(
$messages
as
$message
)
{
$output
[
$path
][]
=
array
(
'code'
=>
$message
->
getCode
(),
'name'
=>
$message
->
getName
(),
'severity'
=>
$message
->
getSeverity
(),
'line'
=>
$message
->
getLine
(),
'char'
=>
$message
->
getChar
(),
'context'
=>
implode
(
"
\n
"
,
array_slice
(
$data
,
$message
->
getLine
()
-
self
::
LINES_OF_CONTEXT
,
self
::
LINES_OF_CONTEXT
*
2
+
1
)),
);
}
return
json_encode
(
$output
).
"
\n
"
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Jul 31, 3:58 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
16382293
Default Alt Text
ArcanistLintJSONRenderer.php (1 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment