netdata/netdata

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

Summary

Maintainability
F
2 wks
Test Coverage

File emitter.py has 952 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: MIT

# Emitter expects events obeying the following grammar:
# stream ::= STREAM-START document* STREAM-END
# document ::= DOCUMENT-START node DOCUMENT-END
Severity: Major
Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 2 days to fix

    Function analyze_scalar has a Cognitive Complexity of 80 (exceeds 5 allowed). Consider refactoring.
    Open

        def analyze_scalar(self, scalar):
    
            # Empty scalar is a special case.
            if not scalar:
                return ScalarAnalysis(scalar=scalar, empty=True, multiline=False,
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 day 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 write_single_quoted has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_single_quoted(self, text, split=True):
            self.write_indicator('\'', True)
            spaces = False
            breaks = False
            start = end = 0
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 day 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 write_folded has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_folded(self, text):
            hints = self.determine_block_hints(text)
            self.write_indicator('>'+hints, True)
            if hints[-1:] == '+':
                self.open_ended = True
    Severity: Minor
    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 day 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

    Emitter has 59 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Emitter:
    
        DEFAULT_TAG_PREFIXES = {
            '!' : '!',
            'tag:yaml.org,2002:' : '!!',
    Severity: Major
    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 day to fix

      Function write_plain has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring.
      Open

          def write_plain(self, text, split=True):
              if self.root_context:
                  self.open_ended = True
              if not text:
                  return
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 day 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 write_double_quoted has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
      Open

          def write_double_quoted(self, text, split=True):
              self.write_indicator('"', True)
              start = end = 0
              while end <= len(text):
                  ch = None
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 7 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 write_literal has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
      Open

          def write_literal(self, text):
              hints = self.determine_block_hints(text)
              self.write_indicator('|'+hints, True)
              if hints[-1:] == '+':
                  self.open_ended = True
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 5 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 choose_scalar_style has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def choose_scalar_style(self):
              if self.analysis is None:
                  self.analysis = self.analyze_scalar(self.event.value)
              if self.event.style == '"' or self.canonical:
                  return '"'
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 3 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 expect_document_start has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
      Open

          def expect_document_start(self, first=False):
              if isinstance(self.event, DocumentStartEvent):
                  if (self.event.version or self.event.tags) and self.open_ended:
                      self.write_indicator('...', True)
                      self.write_indent()
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 3 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 prepare_tag has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepare_tag(self, tag):
              if not tag:
                  raise EmitterError("tag must not be empty")
              if tag == '!':
                  return tag
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 process_tag has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def process_tag(self):
              tag = self.event.tag
              if isinstance(self.event, ScalarEvent):
                  if self.style is None:
                      self.style = self.choose_scalar_style()
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 expect_node has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def expect_node(self, root=False, sequence=False, mapping=False,
                  simple_key=False):
              self.root_context = root
              self.sequence_context = sequence
              self.mapping_context = mapping
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 prepare_tag_prefix has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def prepare_tag_prefix(self, prefix):
              if not prefix:
                  raise EmitterError("tag prefix must not be empty")
              chunks = []
              start = end = 0
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 check_simple_key has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def check_simple_key(self):
              length = 0
              if isinstance(self.event, NodeEvent) and self.event.anchor is not None:
                  if self.prepared_anchor is None:
                      self.prepared_anchor = self.prepare_anchor(self.event.anchor)
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 expect_flow_mapping_key has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def expect_flow_mapping_key(self):
              if isinstance(self.event, MappingEndEvent):
                  self.indent = self.indents.pop()
                  self.flow_level -= 1
                  if self.canonical:
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def __init__(self, stream, canonical=None, indent=None, width=None,
                  allow_unicode=None, line_break=None):
      
              # The stream should have the methods `write` and possibly `flush`.
              self.stream = stream
      Severity: Minor
      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 hr to fix

        Function __init__ has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, scalar, empty, multiline,
        Severity: Major
        Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 hr to fix

          Consider simplifying this complex logical expression.
          Open

                      if (not (self.simple_key_context and
                              (self.analysis.empty or self.analysis.multiline))
                          and (self.flow_level and self.analysis.allow_flow_plain
                              or (not self.flow_level and self.analysis.allow_block_plain))):
                          return ''
          Severity: Major
          Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 1 hr to fix

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

                def expect_first_flow_mapping_key(self):
                    if isinstance(self.event, MappingEndEvent):
                        self.indent = self.indents.pop()
                        self.flow_level -= 1
                        self.write_indicator('}', False)
            Severity: Minor
            Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(self, stream, canonical=None, indent=None, width=None,
            Severity: Minor
            Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if self.encoding:
                                          data = data.encode(self.encoding)
                                      self.stream.write(data)
              Severity: Major
              Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if br == '\n':
                                            self.write_line_break()
                                        else:
                                            self.write_line_break(br)
                                    self.write_indent()
                Severity: Major
                Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if br == '\n':
                                              self.write_line_break()
                                          else:
                                              self.write_line_break(br)
                                      if ch is not None:
                  Severity: Major
                  Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if self.encoding:
                                                data = data.encode(self.encoding)
                                            self.stream.write(data)
                    Severity: Major
                    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if self.encoding:
                                                  data = data.encode(self.encoding)
                                              self.stream.write(data)
                      Severity: Major
                      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if self.encoding:
                                                    data = data.encode(self.encoding)
                                                self.stream.write(data)
                        Severity: Major
                        Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if br == '\n':
                                                      self.write_line_break()
                                                  else:
                                                      self.write_line_break(br)
                                              if ch is not None:
                          Severity: Major
                          Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                    if br == '\n':
                                                        self.write_line_break()
                                                    else:
                                                        self.write_line_break(br)
                                                self.write_indent()
                            Severity: Major
                            Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 45 mins to fix

                              Consider simplifying this complex logical expression.
                              Open

                                      if isinstance(self.event, DocumentStartEvent):
                                          if (self.event.version or self.event.tags) and self.open_ended:
                                              self.write_indicator('...', True)
                                              self.write_indent()
                                          if self.event.version:
                              Severity: Major
                              Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 40 mins to fix

                                Consider simplifying this complex logical expression.
                                Open

                                            if '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z' \
                                                    or ch in '-;/?:@&=+$,_.~*\'()[]'   \
                                                    or (ch == '!' and handle != '!'):
                                                end += 1
                                            else:
                                Severity: Major
                                Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 40 mins to fix

                                  Consider simplifying this complex logical expression.
                                  Open

                                              if ((not self.canonical or tag is None) and
                                                  ((self.style == '' and self.event.implicit[0])
                                                          or (self.style != '' and self.event.implicit[1]))):
                                                  self.prepared_tag = None
                                                  return
                                  Severity: Major
                                  Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 40 mins to fix

                                    Consider simplifying this complex logical expression.
                                    Open

                                                if ch is None or ch in '"\\\x85\u2028\u2029\uFEFF' \
                                                        or not ('\x20' <= ch <= '\x7E'
                                                            or (self.allow_unicode
                                                                and ('\xA0' <= ch <= '\uD7FF'
                                                                    or '\uE000' <= ch <= '\uFFFD'))):
                                    Severity: Major
                                    Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 40 mins to fix

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

                                          def determine_block_hints(self, text):
                                              hints = ''
                                              if text:
                                                  if text[0] in ' \n\x85\u2028\u2029':
                                                      hints += str(self.best_indent)
                                      Severity: Minor
                                      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 need_events has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def need_events(self, count):
                                              level = 0
                                              for event in self.events[1:]:
                                                  if isinstance(event, (DocumentStartEvent, CollectionStartEvent)):
                                                      level += 1
                                      Severity: Minor
                                      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 prepare_tag_handle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def prepare_tag_handle(self, handle):
                                              if not handle:
                                                  raise EmitterError("tag handle must not be empty")
                                              if handle[0] != '!' or handle[-1] != '!':
                                                  raise EmitterError("tag handle must start and end with '!': %r" % handle)
                                      Severity: Minor
                                      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 process_scalar has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def process_scalar(self):
                                              if self.analysis is None:
                                                  self.analysis = self.analyze_scalar(self.event.value)
                                              if self.style is None:
                                                  self.style = self.choose_scalar_style()
                                      Severity: Minor
                                      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 '"'
                                      Severity: Major
                                      Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                    return False
                                        Severity: Major
                                        Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.py - About 30 mins to fix

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

                                              def write_indent(self):
                                                  indent = self.indent or 0
                                                  if not self.indention or self.column > indent   \
                                                          or (self.column == indent and not self.whitespace):
                                                      self.write_line_break()
                                          Severity: Minor
                                          Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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 expect_flow_sequence_item has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                          Open

                                              def expect_flow_sequence_item(self):
                                                  if isinstance(self.event, SequenceEndEvent):
                                                      self.indent = self.indents.pop()
                                                      self.flow_level -= 1
                                                      if self.canonical:
                                          Severity: Minor
                                          Found in src/collectors/python.d.plugin/python_modules/pyyaml3/emitter.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