melexis/warnings-plugin

View on GitHub

Showing 11 of 11 total issues

Function warnings_wrapper has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
Open

def warnings_wrapper(args):
    parser = argparse.ArgumentParser(prog='mlx-warnings')
    group1 = parser.add_argument_group('Configuration command line options')
    group1.add_argument('--coverity', dest='coverity', action='store_true')
    group1.add_argument('-d', '--doxygen', dest='doxygen', action='store_true')
Severity: Minor
Found in src/mlx/warnings/warnings.py - About 5 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Cyclomatic complexity is too high in function warnings_wrapper. (29)
Open

def warnings_wrapper(args):
    parser = argparse.ArgumentParser(prog='mlx-warnings')
    group1 = parser.add_argument_group('Configuration command line options')
    group1.add_argument('--coverity', dest='coverity', action='store_true')
    group1.add_argument('-d', '--doxygen', dest='doxygen', action='store_true')
Severity: Minor
Found in src/mlx/warnings/warnings.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

File warnings.py has 342 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import argparse
import errno
Severity: Minor
Found in src/mlx/warnings/warnings.py - About 4 hrs to fix

    Cyclomatic complexity is too high in method add_code_quality_finding. (15)
    Open

        def add_code_quality_finding(self, match):
            finding = {
                "severity": "major",
                "location": {
                    "path": self.cq_default_path,
    Severity: Minor
    Found in src/mlx/warnings/regex_checker.py by radon

    Cyclomatic Complexity

    Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

    Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

    Construct Effect on CC Reasoning
    if +1 An if statement is a single decision.
    elif +1 The elif statement adds another decision.
    else +0 The else statement does not cause a new decision. The decision is at the if.
    for +1 There is a decision at the start of the loop.
    while +1 There is a decision at the while statement.
    except +1 Each except branch adds a new conditional path of execution.
    finally +0 The finally block is unconditionally executed.
    with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
    assert +1 The assert statement internally roughly equals a conditional statement.
    Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
    Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

    Source: http://radon.readthedocs.org/en/latest/intro.html

    Function add_code_quality_finding has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def add_code_quality_finding(self, match):
            finding = {
                "severity": "major",
                "location": {
                    "path": self.cq_default_path,
    Severity: Minor
    Found in src/mlx/warnings/regex_checker.py - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Consider simplifying this complex logical expression.
    Open

        if args.configfile is not None:
            checker_flags = args.sphinx or args.doxygen or args.junit or args.coverity or args.xmlrunner or args.robot
            warning_args = args.maxwarnings or args.minwarnings or args.exact_warnings
            if checker_flags or warning_args:
                print("Configfile cannot be provided with other arguments")
    Severity: Critical
    Found in src/mlx/warnings/warnings.py - About 1 hr to fix

      Function warnings_wrapper has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      def warnings_wrapper(args):
          parser = argparse.ArgumentParser(prog='mlx-warnings')
          group1 = parser.add_argument_group('Configuration command line options')
          group1.add_argument('--coverity', dest='coverity', action='store_true')
          group1.add_argument('-d', '--doxygen', dest='doxygen', action='store_true')
      Severity: Minor
      Found in src/mlx/warnings/warnings.py - About 1 hr to fix

        Function return_check_limits has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def return_check_limits(self, name=None):
                ''' 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
        Severity: Minor
        Found in src/mlx/warnings/warnings.py - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function substitute_envvar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def substitute_envvar(checker_config, keys):
            """Modifies configuration for checker in-place, resolving any environment variables for ``keys``
        
            Args:
                checker_config (dict): Configuration for a specific WarningsChecker
        Severity: Minor
        Found in src/mlx/warnings/warnings.py - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Refactor this function to reduce its Cognitive Complexity from 40 to the 15 allowed.
        Open

        def warnings_wrapper(args):
        Severity: Critical
        Found in src/mlx/warnings/warnings.py by sonar-python

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
        Open

            def add_code_quality_finding(self, match):
        Severity: Critical
        Found in src/mlx/warnings/regex_checker.py by sonar-python

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

        Severity
        Category
        Status
        Source
        Language