hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.py

Summary

Maintainability
F
2 mos
Test Coverage

File aifc.py has 767 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Stuff to parse AIFF-C and AIFF files.

Unless explicitly stated otherwise, the description below is true
both for AIFF-C files and AIFF files.
Severity: Major
Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.py - About 1 day to fix

    Function _read_comm_chunk has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
    Open

        def _read_comm_chunk(self, chunk):
            self._nchannels = _read_short(chunk)
            self._nframes = _read_long(chunk)
            self._sampwidth = (_read_short(chunk) + 7) // 8
            self._framerate = int(_read_float(chunk))
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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

    Aifc_write has 34 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Aifc_write:
        # Variables used in this class:
        #
        # These variables are user settable through appropriate methods
        # of this class:
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.py - About 4 hrs to fix

      Function _ensure_header_written has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def _ensure_header_written(self, datasize):
              if not self._nframeswritten:
                  if self._comptype in ('ULAW', 'ALAW'):
                      if not self._sampwidth:
                          self._sampwidth = 2
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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 initfp has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def initfp(self, file):
              self._version = 0
              self._decomp = None
              self._convert = None
              self._markers = []
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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

      Aifc_read has 22 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Aifc_read:
          # Variables used in this class:
          #
          # These variables are available to the user though appropriate
          # methods of this class:
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.py - About 2 hrs to fix

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

            def _write_header(self, initlength):
                if self._aifc and self._comptype != 'NONE':
                    self._init_compression()
                self._file.write('FORM')
                if not self._nframes:
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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_compression has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def _init_compression(self):
                if self._comptype == 'G722':
                    self._convert = self._lin2adpcm
                    return
                try:
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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 _write_float has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        def _write_float(f, x):
            import math
            if x < 0:
                sign = 0x8000
                x = x * -1
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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 _readmark has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def _readmark(self, chunk):
                nmarkers = _read_short(chunk)
                # Some files appear to contain invalid counts.
                # Cope with this by testing for EOF.
                try:
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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 open has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def open(f, mode=None):
            if mode is None:
                if hasattr(f, 'mode'):
                    mode = f.mode
                else:
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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 setmark has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def setmark(self, id, pos, name):
                if id <= 0:
                    raise Error, 'marker ID must be > 0'
                if pos < 0:
                    raise Error, 'marker position must be >= 0'
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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 readframes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def readframes(self, nframes):
                if self._ssnd_seek_needed:
                    self._ssnd_chunk.seek(0)
                    dummy = self._ssnd_chunk.read(8)
                    pos = self._soundpos * self._framesize
        Severity: Minor
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.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

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

        Severity: Major
        Found in AppPkg/Applications/Python/Python-2.7.2/Lib/aifc.py and 1 other location - About 2 mos to fix
        vector-uefi/fd/efi/StdLib/lib/python.27/aifc.py on lines 0..957

        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 5679.

        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