vaneseltine/nominally

View on GitHub
nominally/parser.py

Summary

Maintainability
A
0 mins
Test Coverage

File parser.py has 351 lines of code (exceeds 250 allowed). Consider refactoring.
Wontfix

import functools
import re
import typing as T
from collections import abc

Severity: Minor
Found in nominally/parser.py - About 4 hrs to fix

Function word_count_bouncer has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Wontfix

def word_count_bouncer(minimum: int) -> T.Callable[[T.Any], T.Any]:
    """
    Decorate only class/instance methods, enforce word count on first real arg.

    If there are too few (less than minimum) words, return the arguments.
Severity: Minor
Found in nominally/parser.py - About 1 hr 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

Avoid too many return statements within this function.
Wontfix

        return self._remove_from_clusters(clusters, "junior")
Severity: Major
Found in nominally/parser.py - About 30 mins to fix

Function _combine_rightmost_prefixes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

    def _combine_rightmost_prefixes(cls, cluster: Cluster) -> Cluster:
        """Work right-to-left through cluster, joining up prefixes of rightmost"""
        result: Clusters = []

        for word in reversed(cluster):
Severity: Minor
Found in nominally/parser.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

Function _grab_junior has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Wontfix

    def _grab_junior(self, clusters: Clusters) -> Clusters:
        """
        Extract "junior" as suffix unless
        - there is already a generational suffix
        - junior is the first word of the only cluster (e.g. 'junior x. smith')
Severity: Minor
Found in nominally/parser.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

There are no issues that match your filters.

Category
Status