Software Design

Class Diagram

@startuml
class WarningsPlugin {
    #checkerList : WarningsChecker
    +__init__(sphinx=False, doxygen=False, junit=False, verbose=False)
}

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 RegexChecker {
    #{abstract} __init__(name, regex, verbose=False)
    +check(content)
}

class SphinxChecker {
    #{static} String name
    #{static} String regex
    +__init__(verbose=False)
}

class DoxyChecker {
    #{static} String name
    #{static} String regex
    +__init__(verbose=False)
}

class JUnitChecker {
    #{static} String name
    +__init__(verbose=False)
    +check(content)
}

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

@enduml

String Handling

Convention is to use plain python strings everywhere. Where needed the strings can be converted to anything else.

Example: junitparser expects byte array objects, so we encode our string right before passing it to junitparser.

Instrument Module

class mlx.warnings.WarningsPlugin(verbose=False, config_file=None, cq_enabled=False)[source]

Bases: object

activate_checker(checker)[source]

Activate additional checkers after initialization

Parameters:

checker (WarningsChecker) – checker object

activate_checker_name(name)[source]

Activates checker by name

Parameters:

name (str) – checker name

Returns:

WarningsChecker – activated checker object, or None when no checker with the given name exists

check(content)[source]

Function for counting the number of warnings in a specific text

Parameters:

content (str) – The text to parse

config_parser(config)[source]

Parsing configuration dict extracted by previously opened JSON file

Parameters:

config (dict) – Content of configuration file

get_checker(name)[source]

Get checker by name

Parameters:

name (str) – checker name

Returns:

checker object (WarningsChecker)

return_check_limits(name=None)[source]

Function for determining the return value of the script

If the name parameter is set, this function will check (and return) the return value of that checker. If not, this function checks whether the warnings for each registered checker are within the configured limits.

Parameters:

name (WarningsChecker) – The checker for which to check the return value

Returns:

int

0 if the amount of warnings is within limits, the count of warnings otherwise

(or 1 in case of a count of 0 warnings)

return_count(name=None)[source]

Getter function for the amount of found warnings

If the name parameter is set, this function will return the amount of warnings found by that checker. If not, the function will return the sum of the warnings found by all registered checkers.

Parameters:

name (WarningsChecker) – The checker for which to return the amount of warnings (if set)

Returns:

int – Amount of found warnings

set_maximum(maximum)[source]

Setter function for the maximum amount of warnings

Parameters:

maximum (int) – maximum amount of warnings allowed

set_minimum(minimum)[source]

Setter function for the minimum amount of warnings

Parameters:

minimum (int) – minimum amount of warnings allowed

toggle_printout(printout)[source]

Toggle printout of all the parsed content

Useful for command input where we want to print content as well

Parameters:

printout (bool) – True enables the printout, False provides more silent mode

write_code_quality_report(out_file)[source]

Generates the Code Quality report artifact as a JSON file that implements a subset of the Code Climate spec

Parameters:

out_file (str) – Location for the output file

write_counted_warnings(out_file)[source]

Writes counted warnings to the given file

Parameters:

out_file (str) – Location for the output file

mlx.warnings.main()[source]
mlx.warnings.warnings_command(warnings, cmd)[source]

Execute command to obtain input for parsing for warnings

Usually log files are output of the commands. To avoid this additional step this function runs a command instead and parses the stderr and stdout of the command for warnings.

Parameters:
  • warnings (WarningsPlugin) – Object for warnings where errors should be logged

  • cmd (list) – List of commands (str), which should be executed to obtain input for parsing

Returns:

int – Return value of executed command(s)

Raises:

OSError – When program is not installed.

mlx.warnings.warnings_logfile(warnings, log)[source]

Parse logfile for warnings

Parameters:
  • warnings (WarningsPlugin) – Object for warnings where errors should be logged

  • log – Logfile for parsing

Returns:

0 – Log files existed and are parsed successfully 1: Log files did not exist

mlx.warnings.warnings_wrapper(args)[source]