netdata/netdata

View on GitHub
src/collectors/python.d.plugin/python_modules/urllib3/connection.py

Summary

Maintainability
C
7 hrs
Test Coverage

File connection.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: MIT
from __future__ import absolute_import
import datetime
import logging
import os
Severity: Minor
Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.py - About 2 hrs to fix

    Function request_chunked has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def request_chunked(self, method, url, body=None, headers=None):
            """
            Alternative to the common request method, which sends the
            body with chunked encoding and not as one block
            """
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.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 connect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def connect(self):
            # Add certificate verification
            conn = self._new_conn()
    
            hostname = self.host
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.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 __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, host, port=None, key_file=None, cert_file=None,
    Severity: Major
    Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.py - About 1 hr to fix

      Function set_cert has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def set_cert(self, key_file=None, cert_file=None,
      Severity: Major
      Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.py - About 50 mins to fix

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

            def set_cert(self, key_file=None, cert_file=None,
                         cert_reqs=None, ca_certs=None,
                         assert_hostname=None, assert_fingerprint=None,
                         ca_cert_dir=None):
                """
        Severity: Minor
        Found in src/collectors/python.d.plugin/python_modules/urllib3/connection.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