cogniteev/docido-python-sdk

View on GitHub

Showing 49 of 49 total issues

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

class OAuthTokenExpiredError(CrawlerError):
    """Exception class used to notify crawler manager when
    the OAuth token of an account has expired, and needs to be refreshed
    thru Docido front application.
    """
Severity: Major
Found in docido_sdk/crawler/errors.py and 3 other locations - About 35 mins to fix
docido_sdk/crawler/errors.py on lines 11..18
docido_sdk/crawler/errors.py on lines 34..43
docido_sdk/crawler/errors.py on lines 46..56

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

class OAuthTokenPermanentError(CrawlerError):
    """Exception class used to notify crawler manager when
    the OAuth token of an account has been revoked.
    """
    def __init__(self, message=None):
Severity: Major
Found in docido_sdk/crawler/errors.py and 3 other locations - About 35 mins to fix
docido_sdk/crawler/errors.py on lines 11..18
docido_sdk/crawler/errors.py on lines 21..31
docido_sdk/crawler/errors.py on lines 46..56

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

Avoid too many return statements within this function.
Open

    return unicode(text)
Severity: Major
Found in docido_sdk/toolbox/text.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return ' '.join([to_unicode(arg) for arg in text.args])
    Severity: Major
    Found in docido_sdk/toolbox/text.py - About 30 mins to fix

      Function mount_rate_limit_adapters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def mount_rate_limit_adapters(cls, session=None,
                                        rls_config=None, **kwargs):
              """Mount rate-limits adapters on the specified `requests.Session`
              object.
      
      
      Severity: Minor
      Found in docido_sdk/toolbox/http_ext.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 _get_obj_attr has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_obj_attr(cls, obj, path, pos):
              """Resolve one kwargsql expression for a given object and returns
              its result.
      
              :param obj: the object to evaluate
      Severity: Minor
      Found in docido_sdk/toolbox/edsl.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 __getitem__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __getitem__(self, cls):
              """Activate the component instance for the given class, or
              return the existing instance if the component has already been
              activated.
      
      
      Severity: Minor
      Found in docido_sdk/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 fix_mispelled_day has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def fix_mispelled_day(cls, timestr):
              """fix mispelled day when written in english
      
              :return: `None` if the day was not modified, the new date otherwise
              """
      Severity: Minor
      Found in docido_sdk/toolbox/date_ext.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 __call__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, units=1, waits=True, context=None):
              """To be called before consuming a resource that is subject to rate-limits.
      
              :param units:
                Number of units consumed by the API call that is about to be made.
      Severity: Minor
      Found in docido_sdk/toolbox/rate_limits.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