netdata/netdata

View on GitHub
src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py

Summary

Maintainability
F
3 days
Test Coverage

File __init__.py has 281 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# SPDX-License-Identifier: MIT

from error import *

from tokens import *
Severity: Minor
Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py - About 2 hrs to fix

    Function dump_all has 15 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def dump_all(documents, stream=None, Dumper=Dumper,
    Severity: Major
    Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py - About 1 hr to fix

      Function serialize_all has 13 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def serialize_all(nodes, stream=None, Dumper=Dumper,
      Severity: Major
      Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py - About 1 hr to fix

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

        def emit(events, stream=None, Dumper=Dumper,
        Severity: Major
        Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py - About 1 hr to fix

          Function add_implicit_resolver has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def add_implicit_resolver(tag, regexp, first=None,
          Severity: Minor
          Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py - About 35 mins to fix

            Function add_path_resolver has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            def add_path_resolver(tag, path, kind=None, Loader=Loader, Dumper=Dumper):
            Severity: Minor
            Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py - About 35 mins to fix

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

              def serialize_all(nodes, stream=None, Dumper=Dumper,
                      canonical=None, indent=None, width=None,
                      allow_unicode=None, line_break=None,
                      encoding='utf-8', explicit_start=None, explicit_end=None,
                      version=None, tags=None):
              Severity: Minor
              Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.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 dump_all has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              def dump_all(documents, stream=None, Dumper=Dumper,
                      default_style=None, default_flow_style=None,
                      canonical=None, indent=None, width=None,
                      allow_unicode=None, line_break=None,
                      encoding='utf-8', explicit_start=None, explicit_end=None,
              Severity: Minor
              Found in src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.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

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

              def compose_all(stream, Loader=Loader):
                  """
                  Parse all YAML documents in a stream
                  and produce corresponding representation trees.
                  """
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 20..29
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 31..40
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 76..86

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

              def scan(stream, Loader=Loader):
                  """
                  Scan a YAML stream and produce scanning tokens.
                  """
                  loader = Loader(stream)
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 31..40
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 53..63
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 76..86

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

              def parse(stream, Loader=Loader):
                  """
                  Parse a YAML stream and produce parsing events.
                  """
                  loader = Loader(stream)
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 20..29
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 53..63
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 76..86

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

              def load_all(stream, Loader=Loader):
                  """
                  Parse all YAML documents in a stream
                  and produce corresponding Python objects.
                  """
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 20..29
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 31..40
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 53..63

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  if stream is None:
                      if encoding is None:
                          from StringIO import StringIO
                      else:
                          from cStringIO import StringIO
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 136..142

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 41.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Identical blocks of code found in 2 locations. Consider refactoring.
              Open

                  if stream is None:
                      if encoding is None:
                          from StringIO import StringIO
                      else:
                          from cStringIO import StringIO
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 175..181

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 41.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def add_implicit_resolver(tag, regexp, first=None,
                      Loader=Loader, Dumper=Dumper):
                  """
                  Add an implicit scalar detector.
                  If an implicit scalar value matches the given regexp,
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 232..240

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 39.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  try:
                      dumper.open()
                      for node in nodes:
                          dumper.serialize(node)
                      dumper.close()
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 188..194

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 39.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  try:
                      dumper.open()
                      for data in documents:
                          dumper.represent(data)
                      dumper.close()
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 147..153

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 39.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def add_path_resolver(tag, path, kind=None, Loader=Loader, Dumper=Dumper):
                  """
                  Add a path based resolver for the given tag.
                  A path is a list of keys that forms a path
                  to a node in the representation tree.
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 221..230

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 39.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def load(stream, Loader=Loader):
                  """
                  Parse the first YAML document in a stream
                  and produce the corresponding Python object.
                  """
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 42..51

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 38.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              def compose(stream, Loader=Loader):
                  """
                  Parse the first YAML document in a stream
                  and produce the corresponding representation tree.
                  """
              src/collectors/python.d.plugin/python_modules/pyyaml2/__init__.py on lines 65..74

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 38.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              There are no issues that match your filters.

              Category
              Status