kalefranz/auxlib

View on GitHub

Showing 242 of 242 total issues

Cyclomatic complexity is too high in function _git_describe_tags. (8)
Open

def _git_describe_tags(path):
    try:
        call("git update-index --refresh", path, raise_on_error=False)
    except CalledProcessError as e:
        # git is probably not installed
Severity: Minor
Found in auxlib/packaging.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

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

    def __init__(self, field_class, default=NULL, required=True, validation=None,
                 in_dump=True, default_in_dump=True, nullable=False, immutable=False, aliases=()):
        self._type = field_class
        super(ComposableField, self).__init__(default, required, validation,
                                              in_dump, default_in_dump, nullable, immutable,
Severity: Major
Found in auxlib/entity.py and 1 other location - About 2 hrs to fix
auxlib/entity.py on lines 579..583

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

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

Cyclomatic complexity is too high in method __load_source. (8)
Open

    def __load_source(self, source, force_reload=False):
        if force_reload and source.parent_source:
            # TODO: double-check case of reload without force reload for chained configs
            return

Severity: Minor
Found in auxlib/configuration.py by radon

Cyclomatic Complexity

Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

Construct Effect on CC Reasoning
if +1 An if statement is a single decision.
elif +1 The elif statement adds another decision.
else +0 The else statement does not cause a new decision. The decision is at the if.
for +1 There is a decision at the start of the loop.
while +1 There is a decision at the while statement.
except +1 Each except branch adds a new conditional path of execution.
finally +0 The finally block is unconditionally executed.
with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
assert +1 The assert statement internally roughly equals a conditional statement.
Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

Source: http://radon.readthedocs.org/en/latest/intro.html

Function eq has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function eq(a, b, stack) {
    // Identical objects are equal. `0 === -0`, but they aren't identical.
    // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
    if (a === b) return a !== 0 || 1 / a == 1 / b;
    // A strict comparison is necessary because `null == undefined`.
Severity: Major
Found in docs/_theme/basic/static/underscore-1.3.1.js - About 2 hrs to fix

    Function memoizemethod has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def memoizemethod(method):
        """
        Decorator to cause a method to cache it's results in self for each
        combination of inputs and return the cached result on subsequent calls.
        Does not support named arguments or arg values that are not hashable.
    Severity: Minor
    Found in auxlib/decorators.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 remove has 51 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        remove: function( elem, types, handler, selector, mappedTypes ) {
            var j, handleObj, tmp,
                origCount, t, events,
                special, handlers, type,
                namespaces, origType,
    Severity: Major
    Found in docs/_theme/basic/static/jquery-1.11.1.js - About 2 hrs to fix

      Consider simplifying this complex logical expression.
      Open

                      if ( ( mappedTypes || origType === handleObj.origType ) &&
                          ( !handler || handler.guid === handleObj.guid ) &&
                          ( !tmp || tmp.test( handleObj.namespace ) ) &&
                          ( !selector || selector === handleObj.selector || selector === "**" && handleObj.selector ) ) {
                          handlers.splice( j, 1 );
      Severity: Critical
      Found in docs/_theme/basic/static/jquery-1.11.1.js - About 2 hrs to fix

        Cyclomatic complexity is too high in function deprecate_module_with_proxy. (7)
        Open

        def deprecate_module_with_proxy(module_name, module_dict, deprecated_attributes=None):
            """
            Usage:
                deprecate_module_with_proxy(__name__, locals())  # at bottom of module
            """
        Severity: Minor
        Found in auxlib/deprecation.py by radon

        Cyclomatic Complexity

        Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

        Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

        Construct Effect on CC Reasoning
        if +1 An if statement is a single decision.
        elif +1 The elif statement adds another decision.
        else +0 The else statement does not cause a new decision. The decision is at the if.
        for +1 There is a decision at the start of the loop.
        while +1 There is a decision at the while statement.
        except +1 Each except branch adds a new conditional path of execution.
        finally +0 The finally block is unconditionally executed.
        with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
        assert +1 The assert statement internally roughly equals a conditional statement.
        Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
        Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

        Source: http://radon.readthedocs.org/en/latest/intro.html

        Cyclomatic complexity is too high in method __get__. (7)
        Open

            def __get__(self, instance, instance_type):
                try:
                    if instance is None:  # if calling from the class object
                        val = getattr(instance_type, KEY_OVERRIDES_MAP)[self.name]
                    else:
        Severity: Minor
        Found in auxlib/entity.py by radon

        Cyclomatic Complexity

        Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

        Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

        Construct Effect on CC Reasoning
        if +1 An if statement is a single decision.
        elif +1 The elif statement adds another decision.
        else +0 The else statement does not cause a new decision. The decision is at the if.
        for +1 There is a decision at the start of the loop.
        while +1 There is a decision at the while statement.
        except +1 Each except branch adds a new conditional path of execution.
        finally +0 The finally block is unconditionally executed.
        with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
        assert +1 The assert statement internally roughly equals a conditional statement.
        Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
        Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

        Source: http://radon.readthedocs.org/en/latest/intro.html

        Function internalRemoveData has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function internalRemoveData( elem, name, pvt ) {
            if ( !jQuery.acceptData( elem ) ) {
                return;
            }
        
        
        Severity: Minor
        Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

          Function initEvents has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            function initEvents() {
              $(document).on("click", 'a.comment-close', function(event) {
                event.preventDefault();
                hide($(this).attr('id').substring(2));
              });
          Severity: Minor
          Found in docs/_theme/basic/static/websupport.js - About 1 hr to fix

            Function box has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def box(self, instance, instance_type, val):
                    if val is None:
                        return None
                    if isinstance(val, self._type):
                        return val
            Severity: Minor
            Found in auxlib/entity.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 __init__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, **kwargs):
                    for key, field in iteritems(self.__fields__):
                        try:
                            setattr(self, key, kwargs[key])
                        except KeyError:
            Severity: Minor
            Found in auxlib/entity.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 deprecate_module_with_proxy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

            def deprecate_module_with_proxy(module_name, module_dict, deprecated_attributes=None):
                """
                Usage:
                    deprecate_module_with_proxy(__name__, locals())  # at bottom of module
                """
            Severity: Minor
            Found in auxlib/deprecation.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 internalData has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function internalData( elem, name, data, pvt /* Internal Use Only */ ) {
                if ( !jQuery.acceptData( elem ) ) {
                    return;
                }
            
            
            Severity: Minor
            Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

              Function select has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              select = Sizzle.select = function( selector, context, results, seed ) {
                  var i, tokens, token, type, find,
                      compiled = typeof selector === "function" && selector,
                      match = !seed && tokenize( (selector = compiled.selector || selector) );
              
              
              Severity: Minor
              Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

                Function tokenize has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
                    var matched, match, tokens, type,
                        soFar, groups, preFilters,
                        cached = tokenCache[ selector + " " ];
                
                
                Severity: Minor
                Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

                  Cyclomatic complexity is too high in function stringify. (6)
                  Open

                  def stringify(obj, content_max_len=0):
                      def bottle_builder(builder, bottle_object):
                          builder.append("{0} {1}{2} {3}".format(bottle_object.method,
                                                                 bottle_object.path,
                                                                 bottle_object.environ.get('QUERY_STRING', ''),
                  Severity: Minor
                  Found in auxlib/logz.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Cyclomatic complexity is too high in method update. (6)
                  Open

                      def update(self, E=None, **F):
                          # D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
                          # If E present and has a .keys() method, does:     for k in E: D[k] = E[k]
                          # If E present and lacks .keys() method, does:     for (k, v) in E: D[k] = v
                          # In either case, this is followed by: for k in F: D[k] = F[k]
                  Severity: Minor
                  Found in auxlib/entity.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Cyclomatic complexity is too high in class FactoryType. (6)
                  Open

                  class FactoryType(type):
                  
                      def __init__(cls, name, bases, attr):
                          super(FactoryType, cls).__init__(name, bases, attr)
                          if 'skip_registration' in cls.__dict__ and cls.skip_registration:
                  Severity: Minor
                  Found in auxlib/factory.py by radon

                  Cyclomatic Complexity

                  Cyclomatic Complexity corresponds to the number of decisions a block of code contains plus 1. This number (also called McCabe number) is equal to the number of linearly independent paths through the code. This number can be used as a guide when testing conditional logic in blocks.

                  Radon analyzes the AST tree of a Python program to compute Cyclomatic Complexity. Statements have the following effects on Cyclomatic Complexity:

                  Construct Effect on CC Reasoning
                  if +1 An if statement is a single decision.
                  elif +1 The elif statement adds another decision.
                  else +0 The else statement does not cause a new decision. The decision is at the if.
                  for +1 There is a decision at the start of the loop.
                  while +1 There is a decision at the while statement.
                  except +1 Each except branch adds a new conditional path of execution.
                  finally +0 The finally block is unconditionally executed.
                  with +1 The with statement roughly corresponds to a try/except block (see PEP 343 for details).
                  assert +1 The assert statement internally roughly equals a conditional statement.
                  Comprehension +1 A list/set/dict comprehension of generator expression is equivalent to a for loop.
                  Boolean Operator +1 Every boolean operator (and, or) adds a decision point.

                  Source: http://radon.readthedocs.org/en/latest/intro.html

                  Severity
                  Category
                  Status
                  Source
                  Language