Showing 392 of 392 total issues

File utils.py has 413 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding=utf-8
from __future__ import print_function, unicode_literals, absolute_import

"""

Severity: Minor
Found in src/pyff/utils.py - About 5 hrs to fix

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

        if config.error_log is not None:
            if config.error_log.startswith('syslog:'):
                facility = config.error_log[7:]
                h = SysLogLibHandler(facility=facility)
                app.log.error_log.addHandler(h)
    Severity: Major
    Found in src/pyff/mdx.py and 1 other location - About 5 hrs to fix
    src/pyff/mdx.py on lines 869..876

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

    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 config.access_log is not None:
            if config.access_log.startswith('syslog:'):
                facility = config.error_log[7:]
                h = SysLogLibHandler(facility=facility)
                app.log.access_log.addHandler(h)
    Severity: Major
    Found in src/pyff/mdx.py and 1 other location - About 5 hrs to fix
    src/pyff/mdx.py on lines 860..867

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

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

    @pipe
    def certreport(req, *opts):
        """
    Generate a report of the certificates (optionally limited by expiration time or key size) found in the selection.
    
    
    Severity: Minor
    Found in src/pyff/builtins.py - About 4 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 btsListFilter has 122 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        $.fn.btsListFilter = function(inputEl, opts) {
    
            'use strict';
            
            var self = this,
    Severity: Major
    Found in src/pyff/site/static/js/bootstrap-list-filter.src.js - About 4 hrs to fix

      Cyclomatic complexity is too high in function finalize. (21)
      Open

      @pipe
      def finalize(req, *opts):
          """
      Prepares the working document for publication/rendering.
      
      
      Severity: Minor
      Found in src/pyff/builtins.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 acquireWrite has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
      Open

          def acquireWrite(self, timeout=None):
              """Acquire a write lock for the current thread, waiting at most timeout seconds or doing a non-blocking
              check in case timeout is <= 0.
      
          * In case the write lock cannot be serviced due to the deadlock condition mentioned above, a ValueError is raised.
      Severity: Minor
      Found in src/pyff/locks.py - About 4 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 main has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          """
          The main entrypoint for the pyFF cmdline tool.
          """
      
      
      Severity: Minor
      Found in src/pyff/md.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 update has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          def update(self, t, tid=None, ts=None, merge_strategy=None):  # TODO: merge ?
              log.debug("redis store update: %s: %s" % (t, tid))
              relt = root(t)
              ne = 0
              if ts is None:
      Severity: Minor
      Found in src/pyff/store.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 finalize has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      @pipe
      def finalize(req, *opts):
          """
      Prepares the working document for publication/rendering.
      
      
      Severity: Minor
      Found in src/pyff/builtins.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

      Cyclomatic complexity is too high in function main. (16)
      Open

      def main():
          """
          The main entrypoint for the pyFF cmdline tool.
          """
      
      
      Severity: Minor
      Found in src/pyff/md.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 entitiesdescriptor. (16)
      Open

      def entitiesdescriptor(entities,
                             name,
                             lookup_fn=None,
                             cache_duration=None,
                             valid_until=None,
      Severity: Minor
      Found in src/pyff/samlmd.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 _lookup has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

          def _lookup(self, key):
              if key == 'entities' or key is None:
                  return self.entities.values()
              if '+' in key:
                  key = key.strip('+')
      Severity: Minor
      Found in src/pyff/store.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

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

          elif pfx and os.path.exists(os.path.join(pfx, name)):
              with io.open(os.path.join(pfx, name)) as fd:
                  return fd.read()
          elif pkg_resources.resource_exists(__name__, name):
              return pkg_resources.resource_string(__name__, name)
      Severity: Major
      Found in src/pyff/utils.py and 1 other location - About 3 hrs to fix
      src/pyff/utils.py on lines 108..113

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

      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

          elif pfx and os.path.exists(os.path.join(pfx, name)):
              return os.path.join(pfx, name)
          elif pkg_resources.resource_exists(__name__, name):
              return pkg_resources.resource_filename(__name__, name)
          elif pfx and pkg_resources.resource_exists(__name__, "%s/%s" % (pfx, name)):
      Severity: Major
      Found in src/pyff/utils.py and 1 other location - About 3 hrs to fix
      src/pyff/utils.py on lines 78..84

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

      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 _lookup. (15)
      Open

          def _lookup(self, key):
              if key == 'entities' or key is None:
                  return self.entities.values()
              if '+' in key:
                  key = key.strip('+')
      Severity: Minor
      Found in src/pyff/store.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. (15)
      Open

          def update(self, t, tid=None, ts=None, merge_strategy=None):  # TODO: merge ?
              log.debug("redis store update: %s: %s" % (t, tid))
              relt = root(t)
              ne = 0
              if ts is None:
      Severity: Minor
      Found in src/pyff/store.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 search. (15)
      Open

          def search(self, query=None, path=None, page=None, page_limit=10, entity_filter=None, related=None):
              """
      :param query: A string to search for.
      :param path: The repository collection (@Name) to search in - None for search in all collections
      :param page:  When using paged search, the page index
      Severity: Minor
      Found in src/pyff/mdrepo.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 fetch has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          def fetch(self, store=None):
              info = dict()
              info['Resource'] = self.url
              self.add_info(info)
              data = None
      Severity: Minor
      Found in src/pyff/fetch.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

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

                      if args is not None and type(args) is not dict and type(args) is not list and type(args) is not tuple:
                          raise PipeException("Unknown argument type %s" % repr(args))
      Severity: Major
      Found in src/pyff/pipes.py and 1 other location - About 3 hrs to fix
      src/pyff/pipes.py on lines 219..220

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

      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

      Severity
      Category
      Status
      Source
      Language