process
PostProcessor
¶
A post processor to handle a compiler/linter ouput.
Source code in m/ci/celt/core/process.py
__init__(name, celt_config, transform)
¶
Instantiate a PostProcessor
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the compiler/linter. |
required |
celt_config |
Configuration
|
The post processor configuration. |
required |
transform |
Transform
|
Function to generate a list of |
required |
Source code in m/ci/celt/core/process.py
run(payload, config)
¶
Run the processor on the given payload.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload |
str
|
The payload from the compiler/linter. |
required |
config |
Dict[str, Any]
|
A dictionary with rule allowance/ignores. |
required |
Returns:
Type | Description |
---|---|
Res[ProjectStatus]
|
A |
Source code in m/ci/celt/core/process.py
stats_json(project)
¶
Stringify a ProjectStatus
.
Show a dictionary with the total number of violations. Useful when writing an entry for the configuration file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
ProjectStatus
|
The |
required |
Returns:
Type | Description |
---|---|
str
|
The string version of the project status. |
Source code in m/ci/celt/core/process.py
to_str(project)
¶
Stringify a ProjectStatus
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project |
ProjectStatus
|
The |
required |
Returns:
Type | Description |
---|---|
str
|
The string version of the project status. |
Source code in m/ci/celt/core/process.py
filter_reports(reports, regex=None)
¶
Filter the list of file reports based on the file path.
It also removes any file report that does not have any violations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reports |
List[FileReport]
|
List of file reports. |
required |
regex |
Optional[str]
|
The post processor configuration. |
None
|
Returns:
Type | Description |
---|---|
List[FileReport]
|
A list of file reports with at least one violation and file_path |
List[FileReport]
|
matching the provided regex. |
Source code in m/ci/celt/core/process.py
get_project_status(payload, reports, rules_dict, allowed_rules, ignored_rules)
¶
Analyze the rules_dictionary with the allowed and ignored rules.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload |
str
|
The original payload from the compiler/linter. |
required |
reports |
List[FileReport]
|
List of file reports. |
required |
rules_dict |
Dict[str, List[Violation]]
|
A map of rule ids to a list of violations. |
required |
allowed_rules |
Dict[str, int]
|
A dictionary specifying the allowed violations. |
required |
ignored_rules |
Dict[str, str]
|
A dictionary specifying the rules to ignore. |
required |
Returns:
Type | Description |
---|---|
ProjectStatus
|
A ProjectStatus object. |
Source code in m/ci/celt/core/process.py
process(raw_payload, transform, allowed_rules, ignored_rules, celt_config)
¶
Process the output of a compiler/linter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
raw_payload |
str
|
The payload from the compiler/linter. |
required |
transform |
Transform
|
Function to generate a list of |
required |
allowed_rules |
Dict[str, int]
|
A dictionary specifying the allowed violations. |
required |
ignored_rules |
Dict[str, str]
|
A dictionary specifying the rules to ignore. |
required |
celt_config |
Configuration
|
The post processor configuration. |
required |
Returns:
Type | Description |
---|---|
Res[ProjectStatus]
|
A |
Source code in m/ci/celt/core/process.py
replace_filenames(payload, file_prefix)
¶
Replace the prefix of file names.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
payload |
str
|
str The payload from a compiler/linter. |
required |
file_prefix |
Optional[str]
|
Optional[str]
A string of the form |
required |
Returns:
Type | Description |
---|---|
Res[str]
|
A |
Res[str]
|
replaced according to the file_prefix. |
Source code in m/ci/celt/core/process.py
to_rules_dict(reports)
¶
Convert a list of FileReport
to a map of rules to Violation
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reports |
List[FileReport]
|
A list of |
required |
Returns:
Type | Description |
---|---|
Dict[str, List[Violation]]
|
A dictionary mapping rules to a list of |