pyapp-org/pyapp

View on GitHub

Showing 65 of 65 total issues

Cyclomatic complexity is too high in method load. (7)
Open

    def load(self, loader: Loader, apply_method=None):
        """
        Load settings from a loader instance. A loader is an iterator that yields key/value pairs.

        See :py:class:`pyapp.conf.loaders.ModuleLoader` as an example.
Severity: Minor
Found in src/pyapp/conf/__init__.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

Cyclomatic complexity is too high in method checks. (7)
Open

    def checks(self, **kwargs):
        """
        Run checks to ensure settings are valid, secondly run checks against
        individual definitions in settings.

Severity: Minor
Found in src/pyapp/conf/helpers/providers.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 __init__ has 15 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(  # noqa: PLR0913
Severity: Major
Found in src/pyapp/app/__init__.py - About 1 hr to fix

    Cyclomatic complexity is too high in method configure. (6)
    Open

        def configure(
            self,
            default_settings: Union[str, Sequence[str]],
            runtime_settings: str = None,
            additional_loaders: Sequence[Loader] = None,
    Severity: Minor
    Found in src/pyapp/conf/__init__.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

    Cyclomatic complexity is too high in method __iter__. (6)
    Open

        def __iter__(self):
            try:
                self._fp, self.content_type = retrieve_file(self.url)
            except OSError as ex:
                raise InvalidConfiguration(f"Unable to load settings: {self}\n{ex}") from ex
    Severity: Minor
    Found in src/pyapp/conf/loaders/http_loader.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

    Cyclomatic complexity is too high in method _resolve_instance_definition. (6)
    Open

        def _resolve_instance_definition(self, name):
            alias_names = {name}
            while True:
                try:
                    type_name, kwargs = self._instance_definitions[name]
    Severity: Minor
    Found in src/pyapp/conf/helpers/plugins.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

    Cyclomatic complexity is too high in method __call__. (6)
    Open

        def __call__(self, value: str) -> bool:
            """Check if a value is allowed"""
            allow_list, block_list = self.allow_list, self.block_list
    
            if block_list is not None and any(
    Severity: Minor
    Found in src/pyapp/utils/__init__.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 __init__ has 14 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(  # noqa: PLR0913
    Severity: Major
    Found in src/pyapp/app/arguments.py - About 1 hr to fix

      Error: invalid syntax (<unknown>, line 294)</unknown>
      Open

              elif action := TYPE_ACTIONS.get(type_):
      Severity: Minor
      Found in src/pyapp/app/arguments.py by radon

      We encountered an error attempting to analyze this line.

      Error: invalid syntax (<unknown>, line 182)</unknown>
      Open

              if listeners := self.get_listeners(instance):
      Severity: Minor
      Found in src/pyapp/events.py by radon

      We encountered an error attempting to analyze this line.

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

          def check_instance(self, instance_definitions, name, **_):
              """
              Checks for individual instances.
              """
              definition = instance_definitions[name]
      Severity: Minor
      Found in src/pyapp/conf/helpers/plugins.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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def run(
              self, message_level: int = logging.INFO, tags: Sequence[str] = None
          ) -> bool:
              """
              Run the report
      Severity: Minor
      Found in src/pyapp/checks/report.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 _resolve_instance_definition has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def _resolve_instance_definition(self, name):
              alias_names = {name}
              while True:
                  try:
                      type_name, kwargs = self._instance_definitions[name]
      Severity: Minor
      Found in src/pyapp/conf/helpers/plugins.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 inject has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      def inject(
          func: _F = None,
          *,
          from_registry: FactoryRegistry = None,
      ) -> Union[_F, Callable[[_F], _F]]:
      Severity: Minor
      Found in src/pyapp/injection.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 from_parameter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def from_parameter(cls, name: str, parameter: inspect.Parameter) -> "Argument":
              # pylint: disable=too-many-branches,too-many-statements
              """
              Generate an argument from a inspection parameter
      
      
      Severity: Minor
      Found in src/pyapp/app/arguments.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 run_checks_iter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def run_checks_iter(self, tags: Iterable[str] = None, pre_callback=None):
              """Iterate through all registered checks and run each to return messages.
      
              :param tags: Iterable of tags to filter checks by.
              :param pre_callback: Callback triggered before each check is executed.
      Severity: Minor
      Found in src/pyapp/checks/registry.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 _handle_types has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def _handle_types(
              type_, positional: bool, kwargs: Dict[str, Any]
          ) -> Optional[type]:
              """
              Handle types
      Severity: Minor
      Found in src/pyapp/app/arguments.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 flatten_type_annotation has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

      def flatten_type_annotation(annotation) -> Optional[str]:
          """Flatten a type annotation to a string."""
          if isinstance(annotation, ast.Name):
              return annotation.id
      
      
      Severity: Minor
      Found in src/pyapp/documentation/settings.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 execute_report has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def execute_report(  # noqa: PLR0913
      Severity: Major
      Found in src/pyapp/checks/report.py - About 1 hr to fix

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

            def checks(self, **kwargs):
                """
                Run checks to ensure settings are valid, secondly run checks against
                individual definitions in settings.
                """
        Severity: Minor
        Found in src/pyapp/conf/helpers/plugins.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

        Severity
        Category
        Status
        Source
        Language