Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F10615209
StdintLinter.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
StdintLinter.php
View Options
<?php
/**
* Replace native type by there stdint equivalent when needed.
*/
final
class
StdintLinter
extends
ArcanistLinter
{
const
UNSIGNED_CHAR_FOUND
=
1
;
public
function
getInfoName
()
{
return
'lint-stdint'
;
}
public
function
getInfoDescription
()
{
return
pht
(
'Replace native type by there stdint equivalent when needed.'
);
}
public
function
getLinterName
()
{
return
'STDINT'
;
}
public
function
getLinterConfigurationName
()
{
return
'lint-stdint'
;
}
public
function
getLintSeverityMap
()
{
return
array
(
self
::
UNSIGNED_CHAR_FOUND
=>
ArcanistLintSeverity
::
SEVERITY_WARNING
,
);
}
public
function
getLintNameMap
()
{
return
array
(
self
::
UNSIGNED_CHAR_FOUND
=>
pht
(
'`uint8_t should be preferred over '
.
'`unsigned char``.'
),
);
}
public
function
lintPath
(
$path
)
{
$abspath
=
Filesystem
::
resolvePath
(
$path
,
$this
->
getProjectRoot
());
$fileContent
=
Filesystem
::
readFile
(
$abspath
);
if
(
preg_match_all
(
'/unsigned char/'
,
$fileContent
,
$matches
,
PREG_OFFSET_CAPTURE
))
{
foreach
(
$matches
[
0
]
as
$match
)
{
list
(
$unsignedChar
,
$offset
)
=
$match
;
$this
->
raiseLintAtOffset
(
$offset
,
self
::
UNSIGNED_CHAR_FOUND
,
pht
(
'`uint8_t should be preferred over `unsigned char`'
),
$unsignedChar
,
'uint8_t'
);
}
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 23, 10:01 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4551261
Default Alt Text
StdintLinter.php (1 KB)
Attached To
rSTAGING Bitcoin ABC staging
Event Timeline
Log In to Comment