hugoruscitti/pilas

View on GitHub
pilasengine/datos/appdirs.py

Summary

Maintainability
F
4 days
Test Coverage

File appdirs.py has 445 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2005-2010 ActiveState Software Inc.
# Copyright (c) 2013 Eddy Petrișor

Severity: Minor
Found in pilasengine/datos/appdirs.py - About 6 hrs to fix

    Function site_data_dir has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

    def site_data_dir(appname=None, appauthor=None, version=None, multipath=False):
        """Return full path to the user-shared data dir for this application.
    
            "appname" is the name of application.
                If None, just the system directory is returned.
    Severity: Minor
    Found in pilasengine/datos/appdirs.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 user_data_dir has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_data_dir(appname=None, appauthor=None, version=None, roaming=False):
        r"""Return full path to the user-specific data dir for this application.
    
            "appname" is the name of application.
                If None, just the system directory is returned.
    Severity: Minor
    Found in pilasengine/datos/appdirs.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 user_cache_dir has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True):
        r"""Return full path to the user-specific cache dir for this application.
    
            "appname" is the name of application.
                If None, just the system directory is returned.
    Severity: Minor
    Found in pilasengine/datos/appdirs.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 site_config_dir has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
        """Return full path to the user-shared data dir for this application.
    
            "appname" is the name of application.
                If None, just the system directory is returned.
    Severity: Minor
    Found in pilasengine/datos/appdirs.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 user_log_dir has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
        r"""Return full path to the user-specific log dir for this application.
    
            "appname" is the name of application.
                If None, just the system directory is returned.
    Severity: Minor
    Found in pilasengine/datos/appdirs.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 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, appname, appauthor=None, version=None, roaming=False,
    Severity: Minor
    Found in pilasengine/datos/appdirs.py - About 35 mins to fix

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

      def _get_win_folder_with_pywin32(csidl_name):
          from win32com.shell import shellcon, shell
          dir = shell.SHGetFolderPath(0, getattr(shellcon, csidl_name), 0, 0)
          # Try to make this a unicode path because SHGetFolderPath does
          # not return unicode strings when there is unicode data in the
      Severity: Minor
      Found in pilasengine/datos/appdirs.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 _get_win_folder_with_jna has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def _get_win_folder_with_jna(csidl_name):
          import array
          from com.sun import jna
          from com.sun.jna.platform import win32
      
      
      Severity: Minor
      Found in pilasengine/datos/appdirs.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 _get_win_folder_with_ctypes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def _get_win_folder_with_ctypes(csidl_name):
          import ctypes
      
          csidl_const = {
              "CSIDL_APPDATA": 26,
      Severity: Minor
      Found in pilasengine/datos/appdirs.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 2 locations. Consider refactoring.
      Open

          if system == "win32":
              if appauthor is None:
                  appauthor = appname
              const = roaming and "CSIDL_APPDATA" or "CSIDL_LOCAL_APPDATA"
              path = os.path.normpath(_get_win_folder(const))
      Severity: Major
      Found in pilasengine/datos/appdirs.py and 1 other location - About 4 hrs to fix
      pilasengine/datos/appdirs.py on lines 290..308

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

      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 system == "win32":
              if appauthor is None:
                  appauthor = appname
              path = os.path.normpath(_get_win_folder("CSIDL_LOCAL_APPDATA"))
              if appname:
      Severity: Major
      Found in pilasengine/datos/appdirs.py and 1 other location - About 4 hrs to fix
      pilasengine/datos/appdirs.py on lines 77..94

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

      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 appname:
                  if version:
                      appname = os.path.join(appname, version)
                  pathlist = [os.sep.join([x, appname]) for x in pathlist]
      Severity: Major
      Found in pilasengine/datos/appdirs.py and 1 other location - About 1 hr to fix
      pilasengine/datos/appdirs.py on lines 150..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 46.

      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 appname:
                  if version:
                      appname = os.path.join(appname, version)
                  pathlist = [os.sep.join([x, appname]) for x in pathlist]
      Severity: Major
      Found in pilasengine/datos/appdirs.py and 1 other location - About 1 hr to fix
      pilasengine/datos/appdirs.py on lines 245..248

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

      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 appname:
                  if appauthor is not False:
                      path = os.path.join(path, appauthor, appname)
                  else:
                      path = os.path.join(path, appname)
      Severity: Major
      Found in pilasengine/datos/appdirs.py and 1 other location - About 1 hr to fix
      pilasengine/datos/appdirs.py on lines 135..139

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

      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 appname:
                  if appauthor is not False:
                      path = os.path.join(path, appauthor, appname)
                  else:
                      path = os.path.join(path, appname)
      Severity: Major
      Found in pilasengine/datos/appdirs.py and 1 other location - About 1 hr to fix
      pilasengine/datos/appdirs.py on lines 82..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 44.

      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

              pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
      Severity: Minor
      Found in pilasengine/datos/appdirs.py and 1 other location - About 55 mins to fix
      pilasengine/datos/appdirs.py on lines 244..244

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

      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

              pathlist = [os.path.expanduser(x.rstrip(os.sep)) for x in path.split(os.pathsep)]
      Severity: Minor
      Found in pilasengine/datos/appdirs.py and 1 other location - About 55 mins to fix
      pilasengine/datos/appdirs.py on lines 149..149

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

      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 __init__(self, appname, appauthor=None, version=None, roaming=False,
                       multipath=False):
              self.appname = appname
              self.appauthor = appauthor
              self.version = version
      Severity: Major
      Found in pilasengine/datos/appdirs.py and 3 other locations - About 50 mins to fix
      pilasengine/asistente/__init__.py on lines 29..34
      pilas/comportamientos.py on lines 217..222
      pilas/control.py on lines 131..136

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

      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