paulzay/Sendit2

View on GitHub

Showing 21 of 29 total issues

File site.py has 625 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************
Severity: Major
Found in venv/lib/python2.7/site.py - About 1 day to fix

    Function addsitepackages has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring.
    Open

    def addsitepackages(known_paths, sys_prefix=sys.prefix, exec_prefix=sys.exec_prefix):
        """Add site-packages (and possibly site-python) to sys.path"""
        prefixes = [os.path.join(sys_prefix, "local"), sys_prefix]
        if exec_prefix != sys_prefix:
            prefixes.append(os.path.join(exec_prefix, "local"))
    Severity: Minor
    Found in venv/lib/python2.7/site.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 virtual_install_main_packages has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
    Open

    def virtual_install_main_packages():
        f = open(os.path.join(os.path.dirname(__file__), 'orig-prefix.txt'))
        sys.real_prefix = f.read().strip()
        f.close()
        pos = 2
    Severity: Minor
    Found in venv/lib/python2.7/site.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 addusersitepackages has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def addusersitepackages(known_paths):
        """Add a per user site-package to sys.path
    
        Each user has its own python directory with site-packages in the
        home directory.
    Severity: Minor
    Found in venv/lib/python2.7/site.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 _script has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def _script():
        help = """\
        %s [--user-base] [--user-site]
    
        Without arguments print some useful information
    Severity: Minor
    Found in venv/lib/python2.7/site.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 __call__ has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self):
            self.__setup()
            prompt = 'Hit Return for more, or q (and Return) to quit: '
            lineno = 0
            while 1:
    Severity: Minor
    Found in venv/lib/python2.7/site.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 addpackage has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def addpackage(sitedir, name, known_paths):
        """Add a new path to known_paths by combining sitedir and 'name' or execute
        sitedir if it starts with 'import'"""
        if known_paths is None:
            _init_pathinfo()
    Severity: Minor
    Found in venv/lib/python2.7/site.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

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

        if hasattr(os, "getuid") and hasattr(os, "geteuid"):
            # check process uid == effective uid
            if os.geteuid() != os.getuid():
                return None
    Severity: Major
    Found in venv/lib/python2.7/site.py and 1 other location - About 1 hr to fix
    venv/lib/python2.7/site.py on lines 302..305

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

    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

        if hasattr(os, "getgid") and hasattr(os, "getegid"):
            # check process gid == effective gid
            if os.getegid() != os.getgid():
                return None
    Severity: Major
    Found in venv/lib/python2.7/site.py and 1 other location - About 1 hr to fix
    venv/lib/python2.7/site.py on lines 298..301

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

    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

    Function __setup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __setup(self):
            if self.__lines:
                return
            data = None
            for dir in self.__dirs:
    Severity: Minor
    Found in venv/lib/python2.7/site.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 main has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def main():
        global ENABLE_USER_SITE
        virtual_install_main_packages()
        abs__file__()
        paths_in_sys = removeduppaths()
    Severity: Minor
    Found in venv/lib/python2.7/site.py - About 55 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 deeply nested control flow statements.
    Open

                        if _is_64bit:
                            sitedirs.insert(0, lib64_dir)
                        else:
                            sitedirs.append(lib64_dir)
                    try:
    Severity: Major
    Found in venv/lib/python2.7/site.py - About 45 mins to fix

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

      def find_config_files(self):
          found = old_find_config_files(self)
          system_distutils = os.path.join(distutils_path, 'distutils.cfg')
          #if os.path.exists(system_distutils):
          #    found.insert(0, system_distutils)
      Severity: Minor
      Found in venv/lib/python2.7/distutils/__init__.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

      Avoid deeply nested control flow statements.
      Open

                          if home:
                              sitedirs.append(
                                  os.path.join(home,
                                               'Library',
                                               'Python',
      Severity: Major
      Found in venv/lib/python2.7/site.py - About 45 mins to fix

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

        def addsitedir(sitedir, known_paths=None):
            """Add 'sitedir' argument to sys.path if missing and handle .pth files in
            'sitedir'"""
            if known_paths is None:
                known_paths = _init_pathinfo()
        Severity: Minor
        Found in venv/lib/python2.7/site.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

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

                        sitedirs.append(os.path.join(prefix, "local/lib",
                                                     "python" + sys.version[:3],
                                                     "dist-packages"))
        Severity: Minor
        Found in venv/lib/python2.7/site.py and 1 other location - About 40 mins to fix
        venv/lib/python2.7/site.py on lines 256..259

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

        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

                        if sys.version[0] == '2':
                            sitedirs.append(os.path.join(prefix, "lib",
                                                         "python" + sys.version[:3],
                                                         "dist-packages"))
        Severity: Minor
        Found in venv/lib/python2.7/site.py and 1 other location - About 40 mins to fix
        venv/lib/python2.7/site.py on lines 253..255

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

        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

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

        def check_enableusersite():
            """Check if user site directory is safe for inclusion
        
            The function tests for the command line flag (including environment var),
            process uid/gid equal to effective uid/gid.
        Severity: Minor
        Found in venv/lib/python2.7/site.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 abs__file__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def abs__file__():
            """Set all module' __file__ attribute to an absolute path"""
            for m in sys.modules.values():
                if ((_is_jython and not isinstance(m, ModuleType)) or
                    hasattr(m, '__loader__')):
        Severity: Minor
        Found in venv/lib/python2.7/site.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 make_response(jsonify({
        Severity: Major
        Found in app/api/v1/models/models.py - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language