CenterForOpenScience/waterbutler

View on GitHub

Showing 92 of 92 total issues

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

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

    def test(ctx, verbose=False, types=False, nocov=False, provider=None, path=None):
    Severity: Minor
    Found in tasks.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

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

              def _json_api_links(self, resource) -> dict:
                  """Update JSON-API links to add branch, if available"""
                  links = super()._json_api_links(resource)
          
                  ref = None
          Severity: Minor
          Found in waterbutler/providers/gitlab/metadata.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

          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

            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

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

            class GitHubFolderTreeMetadata(BaseGitHubFolderMetadata):
                """Github folder metadata object built from a tree endpoint response."""
            
                @property
                def name(self):
            Severity: Minor
            Found in waterbutler/providers/github/metadata.py and 1 other location - About 40 mins to fix
            waterbutler/providers/github/metadata.py on lines 130..135

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

            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

            class GitHubFileTreeMetadata(BaseGitHubFileMetadata):
                """Github file metadata object built from a tree endpoint response."""
            
                @property
                def name(self):
            Severity: Minor
            Found in waterbutler/providers/github/metadata.py and 1 other location - About 40 mins to fix
            waterbutler/providers/github/metadata.py on lines 138..143

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

            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

            class DropboxUnhandledConflictError(ProviderError):
                def __init__(self, error_data):
                    super().__init__('Dropbox has many unique error messages for code 409 (Conflict), this '
                                     'one was not specifically handled in the provider: {}'.format(error_data),
                                     code=HTTPStatus.CONFLICT)
            Severity: Minor
            Found in waterbutler/providers/dropbox/exceptions.py and 1 other location - About 40 mins to fix
            waterbutler/providers/dropbox/exceptions.py on lines 13..16

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

            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

            class DropboxNamingConflictError(ProviderError):
                def __init__(self, path):
                    super().__init__('Cannot complete action: file or folder already exists at {}'.format(path),
                                     code=HTTPStatus.CONFLICT)
            Severity: Minor
            Found in waterbutler/providers/dropbox/exceptions.py and 1 other location - About 40 mins to fix
            waterbutler/providers/dropbox/exceptions.py on lines 6..10

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

            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 __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,
              Severity: Minor
              Found in waterbutler/core/path.py - About 35 mins to fix

                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, fmt=None, datefmt=None, style='%', pattern=None, mask='***'):
                    Severity: Minor
                    Found in waterbutler/core/logging.py - About 35 mins to fix

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

                          @property
                          def name(self):
                              return os.path.split(self.raw['path_display'])[1]
                      Severity: Major
                      Found in waterbutler/providers/dropbox/metadata.py and 3 other locations - About 35 mins to fix
                      waterbutler/providers/cloudfiles/metadata.py on lines 15..17
                      waterbutler/providers/dropbox/metadata.py on lines 25..27
                      waterbutler/providers/filesystem/metadata.py on lines 36..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 33.

                      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

                              try:
                                  counter = self.redis_conn.incr(redis_key)
                              except RedisError:
                                  raise WaterButlerRedisError('INCR {}'.format(redis_key))
                      Severity: Minor
                      Found in waterbutler/server/api/v1/provider/ratelimiting.py and 1 other location - About 35 mins to fix
                      waterbutler/server/api/v1/provider/ratelimiting.py on lines 44..47

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

                      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 4 locations. Consider refactoring.
                      Open

                          @property
                          def name(self):
                              return os.path.split(self.raw['name'])[1]
                      Severity: Major
                      Found in waterbutler/providers/cloudfiles/metadata.py and 3 other locations - About 35 mins to fix
                      waterbutler/providers/dropbox/metadata.py on lines 25..27
                      waterbutler/providers/dropbox/metadata.py on lines 36..38
                      waterbutler/providers/filesystem/metadata.py on lines 36..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 33.

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

                      Severity
                      Category
                      Status
                      Source
                      Language