Unit Utils.LintRules
Description
Unit which has the own rules of pasc lint, the ones the compiler does not have. The sources are parsed with fcl-passrc, the parser that comes with FPC, also used by fpdoc and pas2js, and the rules walk the tree of each routine. The resolver of fcl-passrc is not used yet, so the rules only need the syntax.
Each rule has an id, like PL001, and its findings are messages like the ones of the compiler, so they go through the same ignore and fail of pasc.json and the same output. The tree has the line of each element but not its column, so a finding is at column 1.
Overview
Functions and Procedures
function CheckRules(const AFileName: string; const AConfig: TLintConfig): TLintMessages; |
function IsSuppressed(const AMessage: TLintMessage; const ALines: TArray<string>): Boolean; |
Constants
RULE_PARSE = 'PL000'; |
RULE_WITH = 'PL001'; |
RULE_EMPTY_EXCEPT = 'PL002'; |
RULE_DESTRUCTOR_INHERITED = 'PL003'; |
RULE_LONG_ROUTINE = 'PL004'; |
RULE_PARAMETERS = 'PL005'; |
RULE_NESTING = 'PL006'; |
Description
Functions and Procedures
function CheckRules(const AFileName: string; const AConfig: TLintConfig): TLintMessages; |
|
Parses a source file with fcl-passrc and returns the findings of the rules. A source that can not be parsed gives a single PL000 note with the reason. The resources of {$R} are ignored, and the includes are searched in the folder of the file.
Parameters
|
function IsSuppressed(const AMessage: TLintMessage; const ALines: TArray<string>): Boolean; |
|
Returns true if the line of the message, or the line above it, has a comment pasc-lint: ignore with the id of the message, like // pasc-lint: ignore PL001, 5024.
Parameters
|
Constants
RULE_PARSE = 'PL000'; |
|
A source that fcl-passrc could not parse. |
RULE_WITH = 'PL001'; |
|
A with statement, which hides where each identifier comes from. |
RULE_EMPTY_EXCEPT = 'PL002'; |
|
An except block, or an on handler, without statements, which hides the error. |
RULE_DESTRUCTOR_INHERITED = 'PL003'; |
|
A destructor that does not call inherited, which leaks what the parent frees. |
RULE_LONG_ROUTINE = 'PL004'; |
|
A routine with more lines than the limit. |
RULE_PARAMETERS = 'PL005'; |
|
A routine with more parameters than the limit. |
RULE_NESTING = 'PL006'; |
|
Statements nested deeper than the limit. |
Generated by PasDoc 1.0.4.