Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Polyspace checker #142

Merged
merged 92 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
d181c3f
Update class diagram
JokeWaumans Jun 13, 2024
9ff1e18
Update config files with code_prover and bug_finder
JokeWaumans Jun 13, 2024
43566cd
Add first changes to add BugFinderChecker and CodeProverChecker
JokeWaumans Jun 13, 2024
681840a
Start implementing PolyspaceChecker with different checkers for each …
JokeWaumans Jun 18, 2024
5e29ef3
Add polyspace checker with different checker for each column name and…
JokeWaumans Jun 25, 2024
0a0004e
Read the file once; loop over checkers
JokeWaumans Jun 25, 2024
5d98602
Fix typo
JokeWaumans Jun 26, 2024
86eb3f4
Add **kwargs to check()
JokeWaumans Jun 26, 2024
e67facd
Add tests for polyspace; update config files with polyspace
JokeWaumans Jun 26, 2024
0a397a9
Fix flake8
JokeWaumans Jun 26, 2024
7776426
Add test with csv file (code prover)
JokeWaumans Jun 26, 2024
eb04028
Add test case for bug finder
JokeWaumans Jun 26, 2024
605ae69
Remove --polyspace argument
JokeWaumans Jun 26, 2024
8b58040
Make PolyspaceCheck inherit from Warningschecker
JokeWaumans Jun 26, 2024
64e7da6
Add testcases with dummy files (code prover and bug finder combined)
JokeWaumans Jun 26, 2024
a70e08a
Add code quality findings for polyspace
JokeWaumans Jun 27, 2024
7a61b26
Use pythonic getter/setter: minimum and maximum property with setter
JokeWaumans Jun 27, 2024
a1d7b35
Add test for code quality of polyspace
JokeWaumans Jun 27, 2024
be2df62
Update gitignore
JokeWaumans Jun 27, 2024
078f5e1
Add correct severity
JokeWaumans Jun 28, 2024
3f8da67
Update severity in code quality JSON file to test with
JokeWaumans Jun 28, 2024
c828bfd
Simplify the configuration file of polyspace
JokeWaumans Jul 1, 2024
acd80d1
Add some debug prints
JokeWaumans Jul 1, 2024
d340b2c
Revert "Add some debug prints"
JokeWaumans Jul 1, 2024
b631fc2
Rename PolyspaceCheck to PolyspaceFamilyChecker
JokeWaumans Jul 2, 2024
84e27d8
Use _minimum and _maximum instead of warn_min and warn_max
JokeWaumans Jul 2, 2024
aed0852
Rename class names to PolyspaceFamilyChecker and PolyspaceSubChecker
JokeWaumans Jul 2, 2024
79e5cde
Revert "Rename class names to PolyspaceFamilyChecker and PolyspaceSub…
JokeWaumans Jul 2, 2024
bf64553
Share cq_findings with sub-checker instances
JasperCraeghs Jul 2, 2024
67c052c
Merge branch 'polyspace-checker' of https://github.com/melexis/warnin…
JasperCraeghs Jul 2, 2024
0b947ba
Delete extra file_extension argument of check(); delete test of cvs f…
JokeWaumans Jul 2, 2024
18c747c
Revert "Delete extra file_extension argument of check(); delete test …
JokeWaumans Jul 2, 2024
e70813e
Use if statements in check() of WarningsPlugin to get rid of file_ext…
JokeWaumans Jul 2, 2024
68c7aa2
Add function check_logfile() to use in warnings_logfile()
JokeWaumans Jul 2, 2024
ffe8415
Rename functions set_minimum and set_maximum to configure_minimum and…
JokeWaumans Jul 2, 2024
ef37b09
Update uml in design
JokeWaumans Jul 2, 2024
722756e
Delete 1 blank line
JokeWaumans Jul 2, 2024
95bfa6c
Polyspace checker is only checked if active
JokeWaumans Jul 2, 2024
a9c65f9
Update help of --config
JokeWaumans Jul 2, 2024
d891da4
Delete green color from code quality
JokeWaumans Jul 3, 2024
a47781b
Merge branch 'polyspace-checker' of github.com:melexis/warnings-plugi…
JokeWaumans Jul 3, 2024
e6dd76f
Use ID column as fingerprint of code quality report
JokeWaumans Jul 3, 2024
8ff4ac8
Fix no green in code quality report; add test
JokeWaumans Jul 3, 2024
4243538
Update readme with Polyspace
JokeWaumans Jul 3, 2024
d3aff4e
Use 'Polyspace: $check' as default of cq_description_template
JokeWaumans Jul 3, 2024
0e93d10
Add exclude config to polyspace; test exclude
JokeWaumans Jul 4, 2024
3f59db9
Add some description about the template of Polyspace checker in the d…
JokeWaumans Jul 4, 2024
3150eb2
Rephrase Polyspace checker documentation with subtitles
JokeWaumans Jul 4, 2024
5978220
Replace spaces with underscore; fix error in "code-block" directive
JokeWaumans Jul 4, 2024
b008247
Move add_code_quality_finding and part of check() to PolyspaceFamiliy…
JokeWaumans Jul 4, 2024
56b591f
Fix error of code-block; add newline
JokeWaumans Jul 4, 2024
ac65bb4
Share cq_default_path with the PolyspaceFamilyCheckers
JokeWaumans Jul 4, 2024
4195a3a
Use key as fingerprint of a code quality finding
JokeWaumans Jul 4, 2024
2b13269
Update class diagram
JokeWaumans Jul 4, 2024
ecd2548
Fix: Title underline too short.
JokeWaumans Jul 4, 2024
f5bf98f
Show all functions and variables in class diagram
JokeWaumans Jul 4, 2024
4f750d9
Add blank line
JokeWaumans Jul 4, 2024
4a6555c
Use dubble ` to get code style in readme
JokeWaumans Jul 4, 2024
973c3fb
Add line and column to code quality if line and col columns exist in …
JokeWaumans Jul 4, 2024
7705862
Use ^^^ instead of ~~~
JokeWaumans Jul 4, 2024
f9ad210
Add -key-mode function-scope to polyspace-results-export in readme
JokeWaumans Jul 4, 2024
dd3b13e
Specify all column available from Polyspace R2024a
JokeWaumans Jul 4, 2024
7ccc2f6
Add dummy Line and Col column; update test files
JokeWaumans Jul 4, 2024
20aeb43
Use hash of the row as fingerprint of the code quality report; update…
JokeWaumans Jul 4, 2024
b03220c
Order imports alphabetically
JokeWaumans Jul 4, 2024
e33fff7
Exclude key column from hash
JokeWaumans Jul 4, 2024
6b0eb26
Update test files with correct fingerprint
JokeWaumans Jul 4, 2024
109bbc9
Remove CSV from docstring
JokeWaumans Jul 4, 2024
dac6ee7
Exclude "new", "status", "severity", "comment", "key" from hash for t…
JokeWaumans Jul 4, 2024
621357b
Merge branch 'polyspace-checker' of github.com:melexis/warnings-plugi…
JokeWaumans Jul 4, 2024
210b180
Use self.__class__.__name__ instead of hardcoded class name
JokeWaumans Jul 4, 2024
26cc0ed
Rephrase sentence
JokeWaumans Jul 4, 2024
9ca41b2
Rename subtitle
JokeWaumans Jul 4, 2024
63a89b5
Fix syntax
JokeWaumans Jul 4, 2024
67ed4f6
Delete tabs
JokeWaumans Jul 4, 2024
1cb7be2
Update the documentation about the default cq template
JokeWaumans Jul 4, 2024
48647aa
Rephrase sentence
JokeWaumans Jul 4, 2024
ca76843
Delete "Default Description Template"; it's mentioned in "Code Qualit…
JokeWaumans Jul 4, 2024
25e465c
Fix link to section title
JokeWaumans Jul 4, 2024
dd51f6c
Add missing comma
JokeWaumans Jul 4, 2024
98ca303
Test with JSON config with removed \ from regex; Delete backslashes i…
JokeWaumans Jul 4, 2024
aee25d0
Document that Line and Col are new columns in Polyspace version R2024a
JokeWaumans Jul 4, 2024
a2724d0
Revert "Add -key-mode function-scope to polyspace-results-export in r…
JokeWaumans Jul 4, 2024
172b42d
Use ligitimate escape backslash
JokeWaumans Jul 5, 2024
87d133d
Add documentation about how the fingerprint is made for Polyspace
JokeWaumans Jul 5, 2024
a3a571c
Update exclude regex to .+\tdummy_function\(\)\tdummy_file_name\.c\t …
JokeWaumans Jul 5, 2024
76f337f
Add clarification about exclude for polyspace
JokeWaumans Jul 5, 2024
9759d61
Add Polyspace to sentence in code quality report
JokeWaumans Jul 5, 2024
4452742
Set enable of Polyspace to true in example
JokeWaumans Jul 5, 2024
b43e257
Rephrase documentation about exclude patterns
JokeWaumans Jul 5, 2024
8f3a5c1
Add "yet" to sentence in documentation
JokeWaumans Jul 5, 2024
c38bbc6
Fix minor typo remarks
JokeWaumans Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ bin/
include/
local/
pip-selfcheck.json
pyvenv.cfg

# Spyder project settings
.spyderproject
Expand All @@ -98,3 +99,6 @@ pip-selfcheck.json

# Offline version file
src/mlx/warnings/__version__.py

# plantuml generation
src/*.plantuml
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved
88 changes: 86 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,68 @@ input file. When this setting is missing, the default value ``true`` is used.
.. |--xunit report.xml| replace:: ``--xunit report.xml``
.. _`--xunit report.xml`: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#xunit-compatible-result-file

Parse for Polyspace Failures
----------------------------

The Polyspace checker requires as input a TSV file exported by Polyspace.
You can find instructions on exporting TSV files in the Polyspace documentation.

Exporting Polyspace Results
^^^^^^^^^^^^^^^^^^^^^^^^^^^

The following commands instruct Polyspace to export the results as a TSV file:

.. code-block:: bash

polyspace-results-export -key-mode function-scope -format csv -results-dir <resultsFolder> <export_options>
# or
polyspace-results-export -key-mode function-scope -format csv -host <hostName> -run-id <runID> <export_options> <polyspace_access_options>

The csv format outputs tab-separated values (TSV).
Each result in the TSV format consists of tab-separated information in columns.
Starting from Polyspace version R2024a these columns are available:
ID, Family, Group, Color, New, Check, Information, Function, File, Status, Severity, Comment, Key, Line and Col.

This file is necessary when you enable Polyspace in the configuration file.
JokeWaumans marked this conversation as resolved.
Show resolved Hide resolved

Configuration
^^^^^^^^^^^^^

Polyspace checking can only be used with a configuration file,
JokeWaumans marked this conversation as resolved.
Show resolved Hide resolved
and it cannot be used together with other checkers enabled.
In this case, only the Polyspace checker will run.

When you enable Polyspace checking in the configuration file,
the checks consist of a key that represents the "family" column of the TSV file.
For example, "run-time check" is the family of Code Prover and "defect" is the family of Bug Finder.
The value of that key is a list, which contains the name of the column to check as a key and
the value of that column to check together with ``min`` and ``max`` values.

Example Checks
^^^^^^^^^^^^^^

In case of Code Prover, you might want to check the ``color`` column on ``red`` or ``orange`` issues.
In case of Bug Finder, you might want to check the ``information`` column on ``impact: high``, ``impact: medium``, or even ``impact: low``.
Other issues, such as "Global variable", can also be handled.
You can specify any column and value you want to check in the configuration file.

Default Description Template
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

``Polyspace: $check`` is the default value for the ``cq_description_template`` variable.
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved

Running the mlx-warnings plugin
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The following commands demonstrate how to run the mlx-warnings plugin with the TSV file:

.. code-block:: bash

# basic Polyspace checker
mlx-warnings --config <configuration_file> <tsv_file>
# Polyspace checker with code quality export
mlx-warnings --code-quality path/to/code_quality.json --config <configuration_file> <tsv_file>

----------------------------------
Configuration File to Pass Options
----------------------------------
Expand Down Expand Up @@ -341,6 +403,20 @@ The values for 'min' and 'max' can be set with environment variables via a
"max": 0
}
]
},
"polyspace": {
"enabled": false,
"cq_description_template": "$PRODUCT $family: $check",
"exclude": [
".+dummy_function\(\)|dummy_file_name\.c"
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved
]
"run-time check": [
{
"color": "red",
"min": 0,
"max": 0
}
]
}
}

Expand Down Expand Up @@ -419,8 +495,16 @@ If a warning doesn't contain a path, ``"cq_default_path"`` from the `configurati
If not configured, ``.gitlab-ci.yml`` will be used as a fallback path.

You can customize the description with ``"cq_description_template"``, see `configuration file to pass options`_.
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved
Its value should be a template for Python's |string.Template|_. The template should contain ``$description`` and has
access to all environment variables, e.g. ``$HOME``.
Its value should be a template for Python's |string.Template|_. The template has access to all environment variables,
e.g. ``$HOME``, and other variables that depend on the checker type:

Polyspace
Any field of a Polyspace defect can be included by using the corresponding
`column title <Exporting Polyspace Results>`_ in lowercase as the variable name.
JasperCraeghs marked this conversation as resolved.
Show resolved Hide resolved
The default template is ``Polyspace: $check``

Other
The template should contain ``$description``, which is the default.

=======================
Issues and New Features
Expand Down
191 changes: 150 additions & 41 deletions docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,57 +10,166 @@ Software Design
Class Diagram
=============

.. uml generated by `pyreverse mlx.warnings --filter ALL -o plantuml`
.. uml::

@startuml
class WarningsPlugin {
#checkerList : WarningsChecker
+__init__(sphinx=False, doxygen=False, junit=False, verbose=False)
@startuml classes
set namespaceSeparator none
class "CoverityChecker" as mlx.warnings.regex_checker.CoverityChecker {
CLASSIFICATION : str
count
name : str
pattern
check(content)
}

class WarningsChecker {
#min_count = 0
#max_count = 0
#count = 0
#verbose = False

#{abstract} __init__(name, verbose=False)
+set_limits(min_count=0, max_count=0,
+{abstract}check(content)
+get_count()
class "DoxyChecker" as mlx.warnings.regex_checker.DoxyChecker {
name : str
pattern
}

class RegexChecker {
#{abstract} __init__(name, regex, verbose=False)
+check(content)
class "JUnitChecker" as mlx.warnings.junit_checker.JUnitChecker {
count
name : str
_check_testcase(testcase)
check(content)
prepare_tree(root_input)
}

class SphinxChecker {
#{static} String name
#{static} String regex
+__init__(verbose=False)
class "PolyspaceChecker" as mlx.warnings.polyspace_checker.PolyspaceChecker {
_cq_description_template : Template
checkers : list
count : int
counted_warnings
cq_default_path
cq_description_template
maximum
minimum
name : str
__init__(verbose)
check(content)
parse_config(config)
return_check_limits()
return_count()
}

class DoxyChecker {
#{static} String name
#{static} String regex
+__init__(verbose=False)
class "PolyspaceFamilyChecker" as mlx.warnings.polyspace_checker.PolyspaceFamilyChecker {
_cq_description_template
check_value
code_quality_severity : dict
column_name
count
cq_description_template
cq_findings : list
family_value
__init__(family_value, column_name, check_value)
add_code_quality_finding(row)
check(content)
return_count()
}

class JUnitChecker {
#{static} String name
+__init__(verbose=False)
+check(content)
class "RegexChecker" as mlx.warnings.regex_checker.RegexChecker {
SEVERITY_MAP : dict
count
name : str
pattern : NoneType
add_code_quality_finding(match)
check(content)
}

WarningsPlugin o-- WarningsChecker
WarningsChecker <|-- RegexChecker
RegexChecker <|-- SphinxChecker
RegexChecker <|-- DoxyChecker
WarningsChecker <|-- JUnitChecker

class "RobotChecker" as mlx.warnings.robot_checker.RobotChecker {
checkers : list
count : int
counted_warnings
maximum
minimum
name : str
check(content)
parse_config(config)
return_check_limits()
return_count()
}
class "RobotSuiteChecker" as mlx.warnings.robot_checker.RobotSuiteChecker {
check_suite_name : bool
is_valid_suite_name : bool
name
__init__(name, check_suite_name)
_check_testcase(testcase)
check(content)
return_count()
}
class "SphinxChecker" as mlx.warnings.regex_checker.SphinxChecker {
name : str
pattern
sphinx_deprecation_regex : str
sphinx_deprecation_regex_in_match : str
include_sphinx_deprecation()
}
class "WarningsChecker" as mlx.warnings.warnings_checker.WarningsChecker {
_counted_warnings : list
_cq_description_template : Template
_maximum : int
_minimum : int
count : int
counted_warnings
cq_default_path : str
cq_description_template
cq_enabled : bool
cq_findings : list
exclude_patterns : list
include_patterns : list
maximum
minimum
name : str
verbose : bool
__init__(verbose)
_is_excluded(content)
_return_error_code()
_search_patterns(content, patterns)
add_patterns(regexes, pattern_container)
{abstract}check(content)
parse_config(config)
print_when_verbose(message)
return_check_limits()
return_count()
}
class "<color:red>WarningsConfigError</color>" as mlx.warnings.exceptions.WarningsConfigError {
}
class "WarningsPlugin" as mlx.warnings.warnings.WarningsPlugin {
_maximum : int
_minimum : int
activated_checkers : dict
count : int
cq_enabled : bool
printout : bool
public_checkers : list
verbose : bool
__init__(verbose, config_file, cq_enabled)
activate_checker(checker)
activate_checker_name(name)
check(content)
check_logfile(file)
config_parser(config)
configure_maximum(maximum)
configure_minimum(minimum)
get_checker(name)
return_check_limits(name)
return_count(name)
toggle_printout(printout)
write_code_quality_report(out_file)
write_counted_warnings(out_file)
}
class "XMLRunnerChecker" as mlx.warnings.regex_checker.XMLRunnerChecker {
name : str
pattern
}
mlx.warnings.junit_checker.JUnitChecker --|> mlx.warnings.warnings_checker.WarningsChecker
mlx.warnings.polyspace_checker.PolyspaceChecker --|> mlx.warnings.warnings_checker.WarningsChecker
mlx.warnings.polyspace_checker.PolyspaceFamilyChecker --|> mlx.warnings.warnings_checker.WarningsChecker
mlx.warnings.regex_checker.CoverityChecker --|> mlx.warnings.regex_checker.RegexChecker
mlx.warnings.regex_checker.DoxyChecker --|> mlx.warnings.regex_checker.RegexChecker
mlx.warnings.regex_checker.RegexChecker --|> mlx.warnings.warnings_checker.WarningsChecker
mlx.warnings.regex_checker.SphinxChecker --|> mlx.warnings.regex_checker.RegexChecker
mlx.warnings.regex_checker.XMLRunnerChecker --|> mlx.warnings.regex_checker.RegexChecker
mlx.warnings.robot_checker.RobotChecker --|> mlx.warnings.warnings_checker.WarningsChecker
mlx.warnings.robot_checker.RobotSuiteChecker --|> mlx.warnings.junit_checker.JUnitChecker
@enduml


String Handling
===============

Expand Down
3 changes: 3 additions & 0 deletions src/mlx/warnings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
'CoverityChecker',
'DoxyChecker',
'JUnitChecker',
'PolyspaceChecker',
'PolyspaceFamilyChecker',
'RobotChecker',
'RobotSuiteChecker',
'SphinxChecker',
Expand All @@ -21,5 +23,6 @@
from .junit_checker import JUnitChecker
from .regex_checker import CoverityChecker, DoxyChecker, SphinxChecker, XMLRunnerChecker
from .robot_checker import RobotChecker, RobotSuiteChecker
from .polyspace_checker import PolyspaceChecker, PolyspaceFamilyChecker
from .warnings import WarningsPlugin, warnings_wrapper
from .warnings_checker import WarningsChecker
Loading
Loading