IdentityPython/pyFF

View on GitHub

Showing 150 of 257 total issues

Function discojson has a Cognitive Complexity of 26 (exceeds 5 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 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 _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 list(self.entities.values())

        if key in self.entities:
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

Resource has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class Resource(Watchable):
    def __init__(self, url: Optional[str], opts: ResourceOpts):
        super().__init__()
        self.url: Optional[str] = url
        self.opts: ResourceOpts = opts
Severity: Minor
Found in src/pyff/resource.py - About 3 hrs to fix

    File pipes.py has 297 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Pipes and plumbing. Plumbing instances are sequences of pipes. Each pipe is called in order to load, select,
    transform, sign or output SAML metadata.
    """
    from __future__ import annotations
    Severity: Minor
    Found in src/pyff/pipes.py - About 3 hrs to fix

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

      def load(req: Plumbing.Request, *opts):
          """
          General-purpose resource fetcher.
      
              :param req: The request
      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

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

          def acquireRead(self, blocking=True, timeout=None):
              """Acquire a read lock for the current thread, waiting at most timeout seconds or doing a
                  non-blocking check in case timeout is <= 0.
      
              * In case timeout is None, the call to acquireRead blocks until the lock request can be serviced.
      Severity: Minor
      Found in src/pyff/locks.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 parse_saml_metadata has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def parse_saml_metadata(
          source: BytesIO, opts: ResourceOpts, base_url=None, validation_errors: Optional[Dict[str, Any]] = None,
      ):
          """Parse a piece of XML and return an EntitiesDescriptor element after validation.
      
      
      Severity: Minor
      Found in src/pyff/samlmd.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 parse has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse(self, resource: Resource, content: str) -> SAMLParserInfo:
              info = SAMLParserInfo(description='SAML Metadata', expiration_time='')
              t, trust_info, expire_time_offset, exception = parse_saml_metadata(
                  unicode_stream(content),
                  base_url=resource.url,
      Severity: Minor
      Found in src/pyff/samlmd.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 __call__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, *args, **kwargs):
              watched = kwargs.pop('watched', None)
              scheduler = kwargs.pop('scheduler', None)
              log.debug("about to schedule icon refresh on {} using {}".format(self, scheduler.state))
              if watched is not None and scheduler is not None:
      Severity: Minor
      Found in src/pyff/store.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 webfinger_handler has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def webfinger_handler(request: Request) -> Response:
          """An implementation the webfinger protocol
          (http://tools.ietf.org/html/draft-ietf-appsawg-webfinger-12)
          in order to provide information about up and downstream metadata available at
          this pyFF instance.
      Severity: Minor
      Found in src/pyff/api.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 update has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def update(self, t, tid=None, etag=None, lazy=True):
              relt = root(t)
              assert relt is not None
      
              if relt.tag == "{%s}EntityDescriptor" % NS['md']:
      Severity: Minor
      Found in src/pyff/store.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 load_resource has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def load_resource(self, getter: Callable[[str], Response]) -> Tuple[Optional[str], int, ResourceInfo]:
              data: Optional[str] = None
              status: int = 500
              info = self.add_info()
              verify_tls = self.opts.verify_tls
      Severity: Minor
      Found in src/pyff/resource.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

      RedisWhooshStore has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class RedisWhooshStore(SAMLStoreBase):  # TODO: This needs a gc mechanism for keys (uuids)
          def json_dict(self, name):
              return LRUProxyDict(
                  JSONDict(key='{}_{}'.format(self._name, name), redis=self._redis, writeback=True), maxsize=config.cache_size
              )
      Severity: Minor
      Found in src/pyff/store.py - About 2 hrs to fix

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

        def check_xml_namespaces(req: Plumbing.Request, *opts):
            """
            Ensure that all namespaces are http or httpd scheme URLs.
        
            :param req: The request
        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 global_md_sources has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def global_md_sources(self):
                from pyff.samlmd import SAMLParserInfo
        
                md_sources = defaultdict(list)
                for r in self.walk():
        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 iprocess has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def iprocess(self, req: Plumbing.Request) -> ElementTree:
                """The inner request pipeline processor.
        
                :param req: The request to run through the pipeline
                """
        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 fork has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def fork(req: Plumbing.Request, *opts):
            """
            Make a copy of the working tree and process the arguments as a pipleline. This essentially resets the working
            tree and allows a new plumbing to run. Useful for producing multiple outputs from a single source.
        
        
        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 _get_index has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def _get_index(self, a, v):
                if a in DINDEX:
                    return self.index[a].get(v, [])
                else:
                    idx = self.index['attr'].setdefault(a, {})
        Severity: Minor
        Found in src/pyff/store.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 mkapp has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def mkapp(*args: Any, **kwargs: Any) -> Any:
            md = kwargs.pop('md', None)
            if md is None:
                md = MDRepository()
        
        
        Severity: Minor
        Found in src/pyff/api.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 emit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

        def emit(req: Plumbing.Request, ctype="application/xml", *opts):
            """
            Returns a UTF-8 encoded representation of the working tree.
        
            :param req: The request
        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

        Severity
        Category
        Status
        Source
        Language