melexis/sphinx-traceability-extension

View on GitHub
mlx/traceability/traceability.py

Summary

Maintainability
A
3 hrs
Test Coverage

File traceability.py has 515 lines of code (exceeds 500 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""
Traceability plugin

Severity: Major
Found in mlx/traceability/traceability.py - About 2 hrs to fix

    Cyclomatic complexity is too high in function query_checklist. (11)
    Open

    def query_checklist(settings, attr_values):
        """ Queries specified API host name for the description of the specified merge request.
    
        Reports a warning if the API host name is invalid, something went wrong with the GET request of the PR/MR,
        or the response does not contain a description.
    Severity: Minor
    Found in mlx/traceability/traceability.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 setup has 53 lines of code (exceeds 40 allowed). Consider refactoring.
    Open

    def setup(app):
        """Extension setup"""
        # Javascript and stylesheet for the tree-view
        app.add_js_file('https://cdn.rawgit.com/aexmachina/jquery-bonsai/master/jquery.bonsai.js')
        app.add_css_file('https://cdn.rawgit.com/aexmachina/jquery-bonsai/master/jquery.bonsai.css')
    Severity: Major
    Found in mlx/traceability/traceability.py - About 1 hr to fix

      Too many statements (54/50)
      Confirmed

      def setup(app):
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when a function or method has too many statements. You should then split it in smaller functions / methods.

      Using open without explicitly specifying an encoding
      Open

          with open(path.join(path.dirname(__file__), 'assets', 'hyperlink_colors.css'), 'w') as css_file:
      Severity: Minor
      Found in mlx/traceability/traceability.py by pylint

      It is better to specify an encoding when opening documents. Using the system default implicitly can create problems on other operating systems. See https://peps.python.org/pep-0597/

      Catching too general exception Exception
      Open

                  except Exception as err:
      Severity: Minor
      Found in mlx/traceability/traceability.py by pylint

      If you use a naked except Exception: clause, you might end up catching exceptions other than the ones you expect to catch. This can hide bugs or make it harder to debug programs when unrelated errors are hidden.

      Formatting a regular string which could be a f-string
      Open

              report_warning('Traceability: attribute {attr} cannot be translated to string'.format(attr=attr))
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  selectors = ".{0}:active,\n.{0}:hover".format(class_name)
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  report_warning('Traceability: item %s not found' % self['reftarget'], self['document'], self['line'])
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  report_warning("Your custom attribute {!r} overlaps with an option of directive(s) {!r} in which your "
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  selectors = ".{0}".format(class_name)
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  selectors = ".{0}:visited".format(class_name)
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  raise TraceabilityException("Checklist attribute values must be two comma-separated strings; got '{}'."
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

              base_url = "{}/repos/{}/pulls/".format(api_host_name, settings['project_id'])
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

              attributes_config[attribute_name] = "({})".format("|".join(regexes))
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

              cli_match = match(r"\s*[\*\-]\s+\[(?P<checkbox>[\sx])\]\s+[*_`~]*(?P<target_id>{})".format(regex), line)
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  headers['Authorization'] = 'token {}'.format(private_token)
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                      report_warning("The query did not return a description. URL = {}. Response = {}.".format(url, response))
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

              base_url = "{}/projects/{}/merge_requests/".format(api_host_name, settings['project_id'])
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                      report_warning("Regex '%s' can take a maximum of 3 colors in traceability_hyperlink_colors." % regex)
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  report_warning("List item {!r} in merge/pull request {} is not defined as a checklist-item."
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                      report_warning("traceability_checklist: failed to GET {!r}: {!r}".format(url, err))
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      Formatting a regular string which could be a f-string
      Open

                  report_warning("Failed to redirect undefined reference %r to %r as this configured item does not exist"
      Severity: Info
      Found in mlx/traceability/traceability.py by pylint

      Used when we detect a string that is being formatted with format() or % which could potentially be a f-string. The use of f-strings is preferred. Requires Python 3.6 and py-version >= 3.6.

      There are no issues that match your filters.

      Category
      Status