netdata/netdata

View on GitHub
src/collectors/python.d.plugin/python_modules/pyyaml3/reader.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def update(self, length):
        if self.raw_buffer is None:
            return
        self.buffer = self.buffer[self.pointer:]
        self.pointer = 0
Severity: Minor
Found in src/collectors/python.d.plugin/python_modules/pyyaml3/reader.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(self, name, position, character, encoding, reason):
Severity: Minor
Found in src/collectors/python.d.plugin/python_modules/pyyaml3/reader.py - About 35 mins to fix

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

        def determine_encoding(self):
            while not self.eof and (self.raw_buffer is None or len(self.raw_buffer) < 2):
                self.update_raw()
            if isinstance(self.raw_buffer, bytes):
                if self.raw_buffer.startswith(codecs.BOM_UTF16_LE):
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/reader.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 forward has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def forward(self, length=1):
            if self.pointer+length+1 >= len(self.buffer):
                self.update(length+1)
            while length:
                ch = self.buffer[self.pointer]
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/reader.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

    There are no issues that match your filters.

    Category
    Status