Unit Utils.Lint
Description
Unit which has the functions used by pasc lint: the messages of the compiler, kept only for the sources of a member, and the configuration in pasc.json that says which ones are ignored and which ones fail.
The dependencies that boss installs in modules are compiled from source with the project, so a build with warnings as errors stops in code that is not ours. The messages are filtered by file after the compiler runs instead.
Overview
Classes, Interfaces, Objects and Records
| Name | Description |
|---|---|
Record TLintMessage |
A message of the compiler for a source file. |
Record TLintConfig |
What is ignored and what fails, by kind or by message number. Errors always fail. |
Functions and Procedures
function LintMessageId(const AMessage: TLintMessage): string; |
function LintKindName(const AKind: TLintKind): string; |
function ParseCompilerMessages(const AOutput, ABaseDir: string): TLintMessages; |
function FilterMemberMessages(const AMessages: TLintMessages; const AMemberDir: string): TLintMessages; |
function ParseCompiledFiles(const AOutput, ABaseDir: string): TArray<string>; |
function FilterMemberFiles(const AFiles: TArray<string>; const AMemberDir: string): TArray<string>; |
function DefaultLintConfig: TLintConfig; |
function LoadLintConfig(const AWorkspaceDir, AMemberName, AMemberPath: string): TLintConfig; |
function IsIgnored(const AConfig: TLintConfig; const AMessage: TLintMessage): Boolean; |
function IsFailing(const AConfig: TLintConfig; const AMessage: TLintMessage): Boolean; |
Types
TLintKind = (...); |
TLintKinds = set of TLintKind; |
TLintMessages = TArray<TLintMessage>; |
Constants
DEFAULT_MAX_ROUTINE_LINES = 80; |
DEFAULT_MAX_PARAMETERS = 6; |
DEFAULT_MAX_NESTING = 4; |
Description
Functions and Procedures
function LintMessageId(const AMessage: TLintMessage): string; |
|
Returns the id of a message as the output shows it: the number of a message of the compiler, like 5093, or the id of a rule, like PL001; empty when there is none.
Parameters
|
function LintKindName(const AKind: TLintKind): string; |
|
Returns the name of a kind, like warning.
Parameters
|
function ParseCompilerMessages(const AOutput, ABaseDir: string): TLintMessages; |
|
Parses the output of lazbuild and returns the messages of the compiler with a file and a position, like file(line,col) Warning: (5093) text. A relative file name is resolved from the last Working Directory that lazbuild wrote, the one of the project or of a package it compiles, or from ABaseDir before the first one. Messages of the linker, the assembler and the resources, numbered from 9000 to 9999, are not about the code and are left out.
Parameters
|
function FilterMemberMessages(const AMessages: TLintMessages; const AMemberDir: string): TLintMessages; |
|
Returns the messages for the sources of a member: files in its folder, not in its lib, backup or modules folders. Each message is returned once, also when two projects of the member compile the same unit. Errors are always kept, wherever they are, because they stop the build.
Parameters
|
function ParseCompiledFiles(const AOutput, ABaseDir: string): TArray<string>; |
|
Parses the output of lazbuild and returns the source files the compiler compiled, from its lines (3104) Compiling file, without the resources. A relative file name is resolved like in ParseCompilerMessages.
Parameters
|
function FilterMemberFiles(const AFiles: TArray<string>; const AMemberDir: string): TArray<string>; |
|
Returns the files that are sources of a member, the ones FilterMemberMessages keeps, each one once.
Parameters
|
function DefaultLintConfig: TLintConfig; |
|
Returns the default configuration: warnings fail, notes and hints are shown. |
function LoadLintConfig(const AWorkspaceDir, AMemberName, AMemberPath: string): TLintConfig; |
|
Reads the lint configuration of a member from the pasc.json of the workspace: "lint": { "ignore": [5024, "PL001"], "fail": ["warning", 5091], "rules": { "PL004": { "max": 60 } }, "members": { "web": { "ignore": [5024] } } } ignore and fail take kinds (error, warning, note, hint), message numbers and ids of rules. rules has the limits of the rules that have one. A member, by name or by folder relative to the root, adds its ignore to the one of the workspace and, when it has fail, replaces it; its rules replace the limits it has. Without pasc.json or lint, the default is returned. Raises an exception for a value that is not a kind, a number or a rule.
Parameters
|
function IsIgnored(const AConfig: TLintConfig; const AMessage: TLintMessage): Boolean; |
|
Returns true if the configuration ignores the message.
Parameters
|
function IsFailing(const AConfig: TLintConfig; const AMessage: TLintMessage): Boolean; |
|
Returns true if the message makes pasc lint fail: an error, a kind in fail or a number in fail.
Parameters
|
Types
TLintKind = (...); |
|
Kind of a message of the compiler. Values
|
TLintKinds = set of TLintKind; |
|
This item has no description. |
TLintMessages = TArray<TLintMessage>; |
|
This item has no description. |
Constants
DEFAULT_MAX_ROUTINE_LINES = 80; |
|
Default limit of rule PL004, in lines of a routine, its header included. |
DEFAULT_MAX_PARAMETERS = 6; |
|
Default limit of rule PL005, in parameters of a routine. |
DEFAULT_MAX_NESTING = 4; |
|
Default limit of rule PL006, in nested if, case, loops, try and with. |
Generated by PasDoc 1.0.4.