hackedteam/vector-edk

View on GitHub
AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.py

Summary

Maintainability
D
2 days
Test Coverage

File gencodec.py has 331 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Unicode Mapping Parser and Codec Generator.

This script parses Unicode mapping files as available from the Unicode
site (ftp://ftp.unicode.org/Public/MAPPINGS/) and creates Python codec
modules from them. The codecs use the standard character mapping codec
Severity: Minor
Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.py - About 3 hrs to fix

    Function python_tabledef_code has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    def python_tabledef_code(varname, map, comments=1, key_precision=2):
    
        l = []
        append = l.append
        append('%s = (' % varname)
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.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 python_mapdef_code has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def python_mapdef_code(varname, map, comments=1, precisions=(2, 4)):
    
        l = []
        append = l.append
        if "IDENTITY" in map:
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.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 readmap has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def readmap(filename):
    
        f = open(filename,'r')
        lines = f.readlines()
        f.close()
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.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 convertdir has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def convertdir(dir, dirprefix='', nameprefix='', comments=1):
    
        mapnames = os.listdir(dir)
        for mapname in mapnames:
            mappathname = os.path.join(dir, mapname)
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.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 rewritepythondir has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def rewritepythondir(dir, dirprefix='', comments=1):
    
        mapnames = os.listdir(dir)
        for mapname in mapnames:
            if not mapname.endswith('.mapping'):
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.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 pymap has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def pymap(name,map,pyfile,encodingname,comments=1):
    Severity: Minor
    Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.py - About 35 mins to fix

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

      def parsecodes(codes, len=len, range=range):
      
          """ Converts code combinations to either a single code integer
              or a tuple of integers.
      
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.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 codegen has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def codegen(name, map, encodingname, comments=1):
      
          """ Returns Python source for the given map.
      
              Comments are included in the source, if comments is true (default).
      Severity: Minor
      Found in AppPkg/Applications/Python/Python-2.7.2/Tools/unicode/gencodec.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