Showing 257 of 257 total issues

Function pipe has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def pipe(*args, **kwargs) -> Callable:
    """
    A decorator that registers a function as a pipeline in pyFF. Functions decorated *should* have the
    following prototype:

Severity: Minor
Found in src/pyff/pipes.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 find_in_document has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def find_in_document(t, member):
    relt = root(t)
    if is_text(member):
        if '!' in member:
            (src, xp) = member.split("!")
Severity: Minor
Found in src/pyff/samlmd.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 entitiesdescriptor has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

def entitiesdescriptor(
Severity: Major
Found in src/pyff/samlmd.py - About 1 hr to fix

    Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

            def __init__(
    Severity: Major
    Found in src/pyff/pipes.py - About 1 hr to fix

      Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Major
      Found in src/pyff/constants.py - About 1 hr to fix

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

        def load_pipe(d: Any) -> Tuple[Callable, Any, str, Optional[Union[str, Dict, List]]]:
            """Return a triple callable,name,args of the pipe specified by the object d.
        
            :param d: The following alternatives for d are allowed:
        
        
        Severity: Minor
        Found in src/pyff/pipes.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 safe_write has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def safe_write(fn, data, mkdirs=False):
            """Safely write data to a file with name fn
            :param fn: a filename
            :param data: some string data to write
            :param mkdirs: create directories along the way (False by default)
        Severity: Minor
        Found in src/pyff/utils.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 release has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def release(self):
                """Release the currently held lock.
        
                * In case the current thread holds no lock, a ValueError is thrown."""
        
        
        Severity: Minor
        Found in src/pyff/locks.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 _setup has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def _setup(self):
                if self.url is not None:
                    if "://" not in self.url:
                        pth = os.path.abspath(self.url)
                        if os.path.isdir(pth):
        Severity: Minor
        Found in src/pyff/resource.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 _filter has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def _filter(req: Plumbing.Request, *opts):
            """
        
            Refines the working document by applying a filter. The filter expression is a subset of the
            select semantics and syntax:
        Severity: Minor
        Found in src/pyff/builtins.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 difftool has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        def difftool():
            """
            diff two saml metadata sources
            """
            args = parse_options("samldiff", __doc__, 'hv', ['help', 'loglevel=', 'version'])
        Severity: Minor
        Found in src/pyff/tools.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 discojson has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        def discojson(e, sources=None, langs=None, fallback_to_favicon=False, icon_store=None):
            if e is None:
                return dict()
        
            title, descr = entity_extended_display(e)
        Severity: Minor
        Found in src/pyff/samlmd.py - About 1 hr to fix

          Function process has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def process(
          Severity: Major
          Found in src/pyff/pipes.py - About 1 hr to fix

            Function prune has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def prune(req: Plumbing.Request, *opts):
                """
            
                Prune the active tree, removing all elements matching
            
            
            Severity: Minor
            Found in src/pyff/builtins.py - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function _store has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def _store(req: Plumbing.Request, *opts):
                """
            
                Save the working document as separate files
            
            
            Severity: Minor
            Found in src/pyff/builtins.py - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function run has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def run(self):
                    while not self.halt:
                        log.debug("waiting for pool {}....".format(self._id))
                        with self.pool:
                            url = self.request.get()
            Severity: Minor
            Found in src/pyff/fetch.py - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function resolve_entities has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def resolve_entities(entities, lookup_fn=None):
                """
            
                :param entities: a set of entities specifiers (lookup is used to find entities from this set)
                :param lookup_fn:  a function used to lookup entities by name
            Severity: Minor
            Found in src/pyff/samlmd.py - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function lookup has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def lookup(self, key):
                    if key == 'entities' or key is None:
                        return self._entities()
            
                    bkey = six.b(key)
            Severity: Minor
            Found in src/pyff/store.py - About 55 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                try:
                    md = MDRepository()
                    for p in args:
                        plumbing(p).process(md, state={'batch': True, 'stats': {}})
                    sys.exit(0)
            Severity: Minor
            Found in src/pyff/md.py and 1 other location - About 55 mins to fix
            src/pyff/tools.py on lines 32..79

            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

                try:
                    rm = Resource()
                    rm.add(r1)
                    rm.add(r2)
                    store = MemoryStore()
            Severity: Minor
            Found in src/pyff/tools.py and 1 other location - About 55 mins to fix
            src/pyff/md.py on lines 30..38

            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

            Severity
            Category
            Status
            Source
            Language