pbrod/Nvector

View on GitHub
src/nvector/_common.py

Summary

Maintainability
A
25 mins
Test Coverage

Function use_docstring has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

def use_docstring(docstring):
    """This decorator modifies the decorated function's docstring with supplied docstring.

    If the function's docstring is None it is replaced with the supplied docstring.
    otherwise it is set to old_docstring.format(super=docstring)
Severity: Minor
Found in src/nvector/_common.py - About 25 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

Catching too general exception Exception
Open

            except Exception:
Severity: Minor
Found in src/nvector/_common.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.

Using open without explicitly specifying an encoding
Open

    with open('readme.txt', 'w') as fid:
Severity: Minor
Found in src/nvector/_common.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/

Missing whitespace around arithmetic operator
Open

        return ''.join(padding+line for line in text.splitlines(True))
Severity: Minor
Found in src/nvector/_common.py by pep8

Surround operators with a single space on either side.

- Always surround these binary operators with a single space on
  either side: assignment (=), augmented assignment (+=, -= etc.),
  comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
  Booleans (and, or, not).

- If operators with different priorities are used, consider adding
  whitespace around the operators with the lowest priorities.

Okay: i = i + 1
Okay: submitted += 1
Okay: x = x * 2 - 1
Okay: hypot2 = x * x + y * y
Okay: c = (a + b) * (a - b)
Okay: foo(bar, key='word', *args, **kwargs)
Okay: alpha[:-i]

E225: i=i+1
E225: submitted +=1
E225: x = x /2 - 1
E225: z = x **y
E225: z = 1and 1
E226: c = (a+b) * (a-b)
E226: hypot2 = x*x + y*y
E227: c = a|b
E228: msg = fmt%(errno, errmsg)

Missing whitespace around arithmetic operator
Open

        summary = summary + fmt.format('Functions', '-'*9, fun_summary)
Severity: Minor
Found in src/nvector/_common.py by pep8

Surround operators with a single space on either side.

- Always surround these binary operators with a single space on
  either side: assignment (=), augmented assignment (+=, -= etc.),
  comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
  Booleans (and, or, not).

- If operators with different priorities are used, consider adding
  whitespace around the operators with the lowest priorities.

Okay: i = i + 1
Okay: submitted += 1
Okay: x = x * 2 - 1
Okay: hypot2 = x * x + y * y
Okay: c = (a + b) * (a - b)
Okay: foo(bar, key='word', *args, **kwargs)
Okay: alpha[:-i]

E225: i=i+1
E225: submitted +=1
E225: x = x /2 - 1
E225: z = x **y
E225: z = 1and 1
E226: c = (a+b) * (a-b)
E226: hypot2 = x*x + y*y
E227: c = a|b
E228: msg = fmt%(errno, errmsg)

Missing whitespace around arithmetic operator
Open

        summary = fmt.format("Classes", '-'*8, class_summary)
Severity: Minor
Found in src/nvector/_common.py by pep8

Surround operators with a single space on either side.

- Always surround these binary operators with a single space on
  either side: assignment (=), augmented assignment (+=, -= etc.),
  comparisons (==, <, >, !=, <=, >=, in, not in, is, is not),
  Booleans (and, or, not).

- If operators with different priorities are used, consider adding
  whitespace around the operators with the lowest priorities.

Okay: i = i + 1
Okay: submitted += 1
Okay: x = x * 2 - 1
Okay: hypot2 = x * x + y * y
Okay: c = (a + b) * (a - b)
Okay: foo(bar, key='word', *args, **kwargs)
Okay: alpha[:-i]

E225: i=i+1
E225: submitted +=1
E225: x = x /2 - 1
E225: z = x **y
E225: z = 1and 1
E226: c = (a+b) * (a-b)
E226: hypot2 = x*x + y*y
E227: c = a|b
E228: msg = fmt%(errno, errmsg)

Argument name ch doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern)
Open

    def indent(text, amount=4, ch=' '):
Severity: Info
Found in src/nvector/_common.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

Argument name ch doesn't conform to '[a-z_][a-z0-9_]{2,30}$' pattern ('[a-z_][a-z0-9_]{2,30}$' pattern)
Open

    def indent(text, amount=4, ch=' '):
Severity: Info
Found in src/nvector/_common.py by pylint

Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

Missing module docstring
Open

import inspect
Severity: Info
Found in src/nvector/_common.py by pylint

Used when a module has no docstring. Empty modules do not require a docstring.

Import outside toplevel (doctest)
Open

    import doctest
Severity: Info
Found in src/nvector/_common.py by pylint

Used when an import statement is used anywhere other than the module toplevel. Move this import to the top of the file.

Missing function or method docstring
Open

    def indent(text, amount=4, ch=' '):
Severity: Info
Found in src/nvector/_common.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

def test_docstrings(filename):
Severity: Info
Found in src/nvector/_common.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

def write_readme(doc):
Severity: Info
Found in src/nvector/_common.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

Missing function or method docstring
Open

    def indent(text, amount=4, ch=' '):
Severity: Info
Found in src/nvector/_common.py by pylint

Used when a function or method has no docstring. Some special methods like init do not require a docstring.

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

    print('Testing docstrings in {0!s}'.format(filename))
Severity: Info
Found in src/nvector/_common.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