CenterForOpenScience/waterbutler

View on GitHub

Showing 62 of 92 total issues

Function _build_and_sign_url has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _build_and_sign_url(self, http_method: str, obj_name: str, content_md5: str='',
Severity: Minor
Found in waterbutler/providers/googlecloud/provider.py - About 45 mins to fix

    Function build_signed_url has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def build_signed_url(self, method, url, data=None, params=None, ttl=100, **kwargs):
    Severity: Minor
    Found in waterbutler/providers/osfstorage/provider.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if marker['name'] == subdir_path:
                                  data.remove(marker)
                                  break
      
      
      Severity: Major
      Found in waterbutler/providers/cloudfiles/provider.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for key, value in headers.items():
                                    self.set_header(key, value)
                            finish_args = [exc.data]
        Severity: Major
        Found in waterbutler/server/api/v1/core.py - About 45 mins to fix

          Function add_file has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def add_file(self, field_name, file_stream, file_name=None, mime='application/octet-stream',
          Severity: Minor
          Found in waterbutler/core/streams/http.py - About 45 mins to fix

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

                def __init__(self, path,
            Severity: Minor
            Found in waterbutler/providers/figshare/path.py - About 45 mins to fix

              Function throttle has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def throttle(concurrency=10, interval=1):
                  def _throttle(func):
                      @functools.wraps(func)
                      async def wrapped(*args, **kwargs):
                          if asyncio.get_event_loop() not in _THROTTLES:
              Severity: Minor
              Found in waterbutler/core/provider.py - About 45 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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, auth: dict,
              Severity: Minor
              Found in waterbutler/core/provider.py - About 35 mins to fix

                Function make_provider has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                def make_provider(name: str, auth: dict, credentials: dict, settings: dict, **kwargs):
                Severity: Minor
                Found in waterbutler/core/utils.py - About 35 mins to fix

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

                      def __init__(self, raw, path, host=None, owner=None, repo=None):
                  Severity: Minor
                  Found in waterbutler/providers/gitlab/metadata.py - About 35 mins to fix

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

                        def __init__(self, fmt=None, datefmt=None, style='%', pattern=None, mask='***'):
                    Severity: Minor
                    Found in waterbutler/core/logging.py - About 35 mins to fix

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

                          def __init__(self,
                      Severity: Minor
                      Found in waterbutler/core/path.py - About 35 mins to fix

                        Function build_signed_url has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def build_signed_url(self, method, url, data=None, params=None, ttl=100, **kwargs):
                                signer = signing.Signer(settings.HMAC_SECRET, settings.HMAC_ALGORITHM)
                                if method.upper() in QUERY_METHODS:
                                    signed = signing.sign_data(signer, params or {}, ttl=ttl)
                                    params = signed
                        Severity: Minor
                        Found in waterbutler/providers/osfstorage/provider.py - About 35 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 adhoc_file_backend has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def adhoc_file_backend(func, was_bound=False, basepath=None):
                            basepath = basepath or settings.ADHOC_BACKEND_PATH
                        
                            @functools.wraps(func)
                            def wrapped(task, *args, **kwargs):
                        Severity: Minor
                        Found in waterbutler/tasks/core.py - About 35 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 __del__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __del__(self):
                                """
                                Manually close all sessions created during the life of the provider instance.  Our code are
                                a slightly modified version of how ``aiohttp-3.5.4`` closes sessions and connectors.
                        
                        
                        Severity: Minor
                        Found in waterbutler/core/provider.py - About 35 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 write_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def write_error(self, status_code, exc_info):
                                sentry_sdk.capture_exception(exc_info)
                                etype, exc, _ = exc_info
                        
                                if issubclass(etype, exceptions.PluginError):
                        Severity: Minor
                        Found in waterbutler/server/api/v0/core.py - About 25 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 parse_request_range has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def parse_request_range(range_header):
                            r"""WB uses tornado's ``httputil._parse_request_range`` function to parse the Range HTTP header
                            and return a tuple representing the range.  Tornado's version returns a tuple suitable for
                            slicing arrays, meaning that a range of 0-1 will be returned as ``(0, 2)``.  WB had been
                            assuming that the tuple would represent the first and last byte positions and was consistently
                        Severity: Minor
                        Found in waterbutler/server/utils.py - About 25 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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __init__(self, file_tuple):
                        
                                filename, stream = file_tuple
                                # Build a ZipInfo instance to use for the file's header and footer
                                self.zinfo = zipfile.ZipInfo(
                        Severity: Minor
                        Found in waterbutler/core/streams/zip.py - About 25 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 async_retry has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                        def async_retry(retries=5, backoff=1, exceptions=(Exception, )):
                        
                            def _async_retry(func):
                        
                                @as_task
                        Severity: Minor
                        Found in waterbutler/core/utils.py - About 25 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 generic_path_validation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def generic_path_validation(cls, path: str) -> None:
                                """Validates a WaterButler specific path, e.g. /folder/file.txt, /folder/
                                :param str path: WaterButler path
                                """
                                if not path:
                        Severity: Minor
                        Found in waterbutler/core/path.py - About 25 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

                        Severity
                        Category
                        Status
                        Source
                        Language