secureCodeBox/secureCodeBox

View on GitHub
scanners/zap-advanced/scanner/zapclient/context/zap_context.py

Summary

Maintainability
C
7 hrs
Test Coverage

File zap_context.py has 341 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

# SPDX-FileCopyrightText: the secureCodeBox authors
#
# SPDX-License-Identifier: Apache-2.0
Severity: Minor
Found in scanners/zap-advanced/scanner/zapclient/context/zap_context.py - About 4 hrs to fix

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

        def _configure_context(self, context: collections.OrderedDict):
            """Configures the ZAP instance with the context.
    
            Parameters
            ----------
    Severity: Minor
    Found in scanners/zap-advanced/scanner/zapclient/context/zap_context.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

    Avoid too many return statements within this function.
    Open

                return 3
    Severity: Major
    Found in scanners/zap-advanced/scanner/zapclient/context/zap_context.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return None
      Severity: Major
      Found in scanners/zap-advanced/scanner/zapclient/context/zap_context.py - About 30 mins to fix

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

            def configure_contexts(self):
                """Configures the ZAP instance with the given list of contexts."""
        
                if self.get_config.has_configurations:
        
        
        Severity: Minor
        Found in scanners/zap-advanced/scanner/zapclient/context/zap_context.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 _configure_alert_filters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _configure_alert_filters(
                self, alert_filters: List[collections.OrderedDict], context_id: int
            ):
                """Protected method to configure the ZAP 'Context / Alert Filters' Settings based on a given ZAP config.
        
        
        Severity: Minor
        Found in scanners/zap-advanced/scanner/zapclient/context/zap_context.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 _configure_context_session_management has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def _configure_context_session_management(
                self, sessions_config: collections.OrderedDict, context_id: int
            ):
                """Protected method to configure the ZAP 'Context / Session Mannagement' Settings based on a given ZAP config.
        
        
        Severity: Minor
        Found in scanners/zap-advanced/scanner/zapclient/context/zap_context.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