cloudsmith-io/cloudsmith-cli

View on GitHub

Showing 97 of 166 total issues

File entitlements.py has 670 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""CLI/Commands - Entitlements."""

import functools
from operator import itemgetter

Severity: Major
Found in cloudsmith_cli/cli/commands/entitlements.py - About 1 day to fix

    File push.py has 457 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """CLI/Commands - Push packages."""
    import math
    import os
    import time
    from datetime import datetime
    Severity: Minor
    Found in cloudsmith_cli/cli/commands/push.py - About 7 hrs to fix

      Function print_entitlements_with_restrictions has a Cognitive Complexity of 45 (exceeds 5 allowed). Consider refactoring.
      Open

      def print_entitlements_with_restrictions(
          opts, data, page_info=None, show_list_info=True
      ):
          # pylint: disable=too-many-locals
          """Print entitlements (with restrictions) as a table or output in another format."""
      Severity: Minor
      Found in cloudsmith_cli/cli/commands/entitlements.py - About 6 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 create_push_handlers has a Cognitive Complexity of 35 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_push_handlers():
          """Create a handler for upload per package format."""
          # pylint: disable=fixme
          # HACK: hacky territory - Dynamically generate a handler for each of the
          # package formats, until we have slightly more clever 'guess type'
      Severity: Minor
      Found in cloudsmith_cli/cli/commands/push.py - About 5 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

      Options has 39 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Options:
          """Options object that holds config for the application."""
      
          def __init__(self, *args, **kwargs):
              """Initialise a new Options object."""
      Severity: Minor
      Found in cloudsmith_cli/cli/config.py - About 5 hrs to fix

        Function handle_api_exceptions has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
        Open

        def handle_api_exceptions(
            ctx, opts, context_msg=None, nl=False, exit_on_error=True, reraise_on_error=False
        ):
            """Context manager that handles API exceptions."""
            # flake8: ignore=C901
        Severity: Minor
        Found in cloudsmith_cli/cli/exceptions.py - About 5 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

        File upstream.py has 347 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """CLI/Commands - create, retrieve, update or delete repository upstreams."""
        
        import json
        
        import click
        Severity: Minor
        Found in cloudsmith_cli/cli/commands/upstream.py - About 4 hrs to fix

          File config.py has 339 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """CLI - Configuration."""
          
          import os
          import re
          import threading
          Severity: Minor
          Found in cloudsmith_cli/cli/config.py - About 4 hrs to fix

            Function wait_for_package_sync has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
            Open

            def wait_for_package_sync(
                ctx, opts, owner, repo, slug, wait_interval, skip_errors, attempts=3
            ):
                """Wait for a package to synchronise (or fail)."""
                # pylint: disable=too-many-locals
            Severity: Minor
            Found in cloudsmith_cli/cli/commands/push.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

            File tags.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """CLI/Commands - List objects."""
            
            from operator import itemgetter
            
            import click
            Severity: Minor
            Found in cloudsmith_cli/cli/commands/tags.py - About 2 hrs to fix

              Function create_requests_session has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
              Open

              def create_requests_session(
                  retries=None,
                  backoff_factor=None,
                  status_forcelist=None,
                  pools_size=4,
              Severity: Minor
              Found in cloudsmith_cli/core/rest.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_values_into_opts has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _load_values_into_opts(opts, values):
                      for k, v in values.items():
                          if v is None:
                              continue
                          if isinstance(v, str):
              Severity: Minor
              Found in cloudsmith_cli/cli/config.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

              File decorators.py has 272 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              """CLI - Decorators."""
              
              import functools
              
              import click
              Severity: Minor
              Found in cloudsmith_cli/cli/decorators.py - About 2 hrs to fix

                Function get_details has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                Open

                def get_details(exc):
                    """Get the details from the exception."""
                    detail = None
                    fields = collections.OrderedDict()
                
                
                Severity: Minor
                Found in cloudsmith_cli/cli/exceptions.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 create_config_files has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                def create_config_files(ctx, opts, api_key):
                    """Create default config files."""
                    # pylint: disable=unused-argument
                    config_reader = opts.get_config_reader()
                    creds_reader = opts.get_creds_reader()
                Severity: Minor
                Found in cloudsmith_cli/cli/commands/login.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

                File license.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """CLI/Commands - create, retrieve, update or delete license policies."""
                
                import json
                
                import click
                Severity: Minor
                Found in cloudsmith_cli/cli/commands/policy/license.py - About 2 hrs to fix

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

                      def request(
                          self,
                          method,
                          url,
                          query_params=None,
                  Severity: Minor
                  Found in cloudsmith_cli/core/rest.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 initialise_api has 13 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def initialise_api(
                  Severity: Major
                  Found in cloudsmith_cli/core/api/init.py - About 1 hr to fix

                    Function maybe_print_as_json has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def maybe_print_as_json(opts, data, page_info=None):
                        """Maybe print data as JSON."""
                        if opts.output not in ("json", "pretty_json"):
                            return False
                    
                    
                    Severity: Minor
                    Found in cloudsmith_cli/cli/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 list_repos has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                    Open

                    def list_repos(owner=None, **kwargs):
                        """List repositories in a namespace."""
                        client = get_repos_api()
                    
                        api_kwargs = {}
                    Severity: Minor
                    Found in cloudsmith_cli/core/api/repos.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