kalefranz/auxlib

View on GitHub

Showing 242 of 242 total issues

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

class EntityEncoder(JSONEncoder):
    # json.dumps(obj, cls=SetEncoder)
    def default(self, obj):
        if hasattr(obj, 'dump'):
            return obj.dump()
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 method default. (6)
Open

    def default(self, obj):
        if hasattr(obj, 'dump'):
            return obj.dump()
        elif hasattr(obj, '__json__'):
            return obj.__json__()
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 method dump. (6)
Open

    def dump(self):
        return odict((field.name, field.dump(self, self.__class__, value))
                     for field, value in ((field, getattr(self, field.name, NULL))
                                          for field in self.__dump_fields())
                     if value is not NULL and not (value is field.default
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 method validate. (6)
Open

    def validate(self):
        # TODO: here, validate should only have to determine if the required keys are set
        try:
            reduce(lambda _, name: getattr(self, name),
                   (name for name, field in iteritems(self.__fields__) if field.required)
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 function open_package_file. (6)
Open

def open_package_file(file_path, package_name):
    file_path = expand(file_path)

    # look for file at relative path
    if exists(file_path):
Severity: Minor
Found in auxlib/path.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 function clear_memoized_methods. (6)
Open

def clear_memoized_methods(obj, *method_names):
    """
    Clear the memoized method or @memoizedproperty results for the given
    method names from the given object.

Severity: Minor
Found in auxlib/decorators.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 __call__. (6)
Open

    def __call__(cls, *args):
        if 'factory' in cls.__dict__:
            if args and args[0]:
                return cls.factory.get_instance(args[0])
            else:
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

Function matcherFromTokens has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function matcherFromTokens( tokens ) {
    var checkContext, matcher, j,
        len = tokens.length,
        leadingRelative = Expr.relative[ tokens[0].type ],
        implicitRelative = leadingRelative || Expr.relative[" "],
Severity: Minor
Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

    Function addComment has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function addComment(form) {
        var node_id = form.find('input[name="node"]').val();
        var parent_id = form.find('input[name="parent"]').val();
        var text = form.find('textarea[name="comment"]').val();
        var proposal = form.find('textarea[name="proposal"]').val();
    Severity: Minor
    Found in docs/_theme/basic/static/websupport.js - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

                  if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
                      ( support.htmlSerialize || !rnoshimcache.test( value )  ) &&
                      ( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
                      !wrapMap[ (rtagName.exec( value ) || [ "", "" ])[ 1 ].toLowerCase() ] ) {
      
      
      Severity: Critical
      Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

        if (!jQuery.browser) {
          jQuery.uaMatch = function(ua) {
            ua = ua.toLowerCase();
        
            var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
        Severity: Critical
        Found in docs/_theme/basic/static/doctools.js - About 1 hr to fix

          Function on has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
                  var type, origFn;
          
                  // Types can be a map of types/handlers
                  if ( typeof types === "object" ) {
          Severity: Minor
          Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

            Function val has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                val: function( value ) {
                    var hooks, ret, isFunction,
                        elem = this[0];
            
                    if ( !arguments.length ) {
            Severity: Minor
            Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

              Function stop has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  stop: function( type, clearQueue, gotoEnd ) {
                      var stopQueue = function( hooks ) {
                          var stop = hooks.stop;
                          delete hooks.stop;
                          stop( gotoEnd );
              Severity: Minor
              Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

                Function comment has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  $.fn.comment = function() {
                    return this.each(function() {
                      var id = $(this).attr('id').substring(1);
                      var count = COMMENT_METADATA[id];
                      var title = count + ' comment' + (count == 1 ? '' : 's');
                Severity: Minor
                Found in docs/_theme/basic/static/websupport.js - About 1 hr to fix

                  Function extend has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  jQuery.extend = jQuery.fn.extend = function() {
                      var src, copyIsArray, copy, name, options, clone,
                          target = arguments[0] || {},
                          i = 1,
                          length = arguments.length,
                  Severity: Minor
                  Found in docs/_theme/basic/static/jquery-1.11.1.js - About 1 hr to fix

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

                        try:
                            attr = _get_attr(search_maps[_map_index], key, aliases)
                            return attr if attr is not None else find_or_raise(key, search_maps[1:], aliases)
                    Severity: Major
                    Found in auxlib/ish.py and 1 other location - About 1 hr to fix
                    auxlib/ish.py on lines 47..49

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

                    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

                        try:
                            attr = _get_attr(search_maps[_map_index], key, aliases)
                            return attr if attr is not None else find_or_none(key, search_maps[1:], aliases)
                    Severity: Major
                    Found in auxlib/ish.py and 1 other location - About 1 hr to fix
                    auxlib/ish.py on lines 59..61

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

                    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 box has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def box(self, instance, instance_type, val):
                            if val is None:
                                return None
                            elif isinstance(val, string_types):
                                raise ValidationError("Attempted to assign a string to ListField {0}"
                    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 make_immutable has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def make_immutable(value):
                        # this function is recursive, and if nested data structures fold back on themselves,
                        #   there will likely be recursion errors
                        if isinstance(value, Mapping):
                            if isinstance(value, frozenodict):
                    Severity: Minor
                    Found in auxlib/collection.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

                    Severity
                    Category
                    Status
                    Source
                    Language