grappa-py/grappa

View on GitHub

Showing 31 of 45 total issues

Function run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self, error):
        if not hasattr(error, 'operator'):
            return None

        # Custom value human-friendly message
Severity: Minor
Found in grappa/reporters/subject.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

Function render_code has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def render_code(self, trace):
        lmin = trace.lineno - CodeReporter.LINES
        lmax = trace.lineno + CodeReporter.LINES
        max_len = max(len(str(lmin)), len(str(lmax)))

Severity: Minor
Found in grappa/reporters/code.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

Function match has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def match(self, subject):
        if subject is None or subject is 0:  # noqa F632
            return True

        if subject in (True, False):
Severity: Minor
Found in grappa/operators/empty.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

Function get_expected has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def get_expected(self, operator=None, defaults=None):
        # Expected value
        expected = self.from_operator('expected', defaults, operator=operator)

        if isinstance(expected, tuple):
Severity: Minor
Found in grappa/reporters/assertion.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

Function _match_suboperator has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def _match_suboperator(self, name):
        def create(operator):
            return self._resolver.run_matcher(operator(self._test._ctx))

        # Check that operator has suboperators
Severity: Minor
Found in grappa/assertion.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

Function observe has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def observe(matcher):
        """
        Internal decorator to trigger operator hooks before/after
        matcher execution.
        """
Severity: Minor
Found in grappa/operator.py - About 55 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 normalize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def normalize(self, value, size=50, use_raw=True):
        if value is None:
            return value

        try:
Severity: Minor
Found in grappa/reporters/base.py - About 55 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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, context=None, operator_name=None, fn=None,
Severity: Major
Found in grappa/operator.py - About 50 mins to fix

    Function mock_implementation_validator has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def mock_implementation_validator(func):
        """
        Validate that a mock conform to the implementation required to run
        have_been and have_been_with operators.
    
    
    Severity: Minor
    Found in grappa/decorators.py - About 45 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 match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def match(self, subject, *values):
            if isinstance(subject, self.NORMALIZE_TYPES):
                subject = list(subject)
            elif isinstance(subject, collections_abc.Mapping):
                subject = list(subject.values())
    Severity: Minor
    Found in grappa/operators/contain.py - About 45 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 match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def match(self, subject, *args, **kwargs):
            success_reasons = []
            for name in args:
                has_property, reason = self._has_property(subject, name)
                if not has_property:
    Severity: Minor
    Found in grappa/operators/property.py - About 45 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 match has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def match(self, subject, *keys):
            if not isinstance(subject, collections_abc.Mapping):
                return False, ['subject is not a dict type']
    
            reasons = []
    Severity: Minor
    Found in grappa/operators/keys.py - About 45 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 delegator has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def delegator(assertion, subject, expected, *args, **kw):
    Severity: Minor
    Found in grappa/decorators.py - About 35 mins to fix

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

      def register_operators(*operators):
          """
          Registers one or multiple operators in the test engine.
          """
          def validate(operator):
      Severity: Minor
      Found in grappa/engine.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 _has_property has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _has_property(self, subject, name, *args):
              if args:
                  try:
                      value = getattr(subject, name)
                  except AttributeError:
      Severity: Minor
      Found in grappa/operators/property.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 _matches_any has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _matches_any(self, expected, subject):
              if len(subject) == 0:
                  return False, 'empty item'
      
              if isinstance(subject, six.string_types):
      Severity: Minor
      Found in grappa/operators/contain.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 operator has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def operator(name=None, operators=None, aliases=None, kind=None):
          """
          Registers a new operator function in the test engine.
      
          Arguments:
      Severity: Minor
      Found in grappa/decorators.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 run_assertions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def run_assertions(self, ctx):
              # Trigger assertion functions
              for assertion in self.engine.assertions:
                  # Store current subject
                  subject = ctx.subject
      Severity: Minor
      Found in grappa/runner.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 __init__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, context=None, operator_name=None, fn=None,
                       kind=None, aliases=None, operators=None, suboperators=None):
              if inspect.isfunction(fn):
                  self.match = fn
              if kind:
      Severity: Minor
      Found in grappa/operator.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

      Avoid too many return statements within this function.
      Open

              return False
      Severity: Major
      Found in grappa/operators/empty.py - About 30 mins to fix
        Severity
        Category
        Status
        Source
        Language