CodeTeam/tcrudge

View on GitHub

Showing 15 of 15 total issues

File handlers.py has 705 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Module contains basic handlers:

* BaseHandler - to be used for custom handlers. For instance - RPC, if you wish.
* ApiHandler - Abstract for API handlers above.
Severity: Major
Found in tcrudge/handlers.py - About 1 day to fix

    Function to_dict has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_dict(self, recurse=True):
            """
            Convert the current schema to a `dict`.
            """
            # start with existing fields
    Severity: Minor
    Found in tcrudge/utils/schema.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

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

        with open(init_py) as f:
            for line in f:
                match = regexp.match(line)
                if match is not None:
                    return match.group(1)
    Severity: Major
    Found in docs/conf.py and 1 other location - About 2 hrs to fix
    setup.py on lines 42..48

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

    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

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

        with open(init_py) as f:
            for line in f:
                match = regexp.match(line)
                if match is not None:
                    return match.group(1)
    Severity: Major
    Found in setup.py and 1 other location - About 2 hrs to fix
    docs/conf.py on lines 65..71

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

    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

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

    class Schema(object):  # pragma: no cover
        """
        Basic schema generator class. Schema objects can be loaded up
        with existing schemas and objects before being serialized.
        """
    Severity: Minor
    Found in tcrudge/utils/schema.py - About 2 hrs to fix

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

      def perm_roles(items):
          """
          Check roles from input list. Auth logic is up to user.
          """
      
      
      Severity: Minor
      Found in tcrudge/decorators.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 add_schema has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_schema(self, schema):
              """
              Merges in an existing schema.
              arguments:
              * `schema` (required - `dict` or `Schema`):
      Severity: Minor
      Found in tcrudge/utils/schema.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 _add_type has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _add_type(self, val_type):
              if isinstance(val_type, (str, dict)):
                  if val_type not in self._type:
                      self._type.append(val_type)
              elif isinstance(val_type, list):
      Severity: Minor
      Found in tcrudge/utils/schema.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 qs_filter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def qs_filter(cls, qs, flt, value, process_value=True):
              """
              Private method to set WHERE part of query.
              If required, Django-style filter is available via qs.filter()
              and peewee.DQ - this method provides joins.
      Severity: Minor
      Found in tcrudge/handlers.py - About 55 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 to_schema has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def to_schema(cls, excluded=None):
              """
              Generates JSON schema from ORM model. User can exclude some fields
              from serialization, by default the only fields to exclude are
              pagination settings.
      Severity: Minor
      Found in tcrudge/models.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 isinstance(it, dict):
                                  res["anyOf"].append(it)
                              else:
                                  res["anyOf"].append({'type': it})
                          properties[key_prop] = res
      Severity: Major
      Found in tcrudge/utils/schema.py - About 45 mins to fix

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

            def get_queryset(self, paginate=True):
                """
                Get queryset for model.
                Override this method to change logic.
        
        
        Severity: Minor
        Found in tcrudge/handlers.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

        def response_json(handler, response):
            """
            Default JSON response.
        
            Sets JSON content type to given handler.
        Severity: Minor
        Found in tcrudge/response.py and 1 other location - About 35 mins to fix
        tcrudge/response.py on lines 32..44

        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

        def response_msgpack(handler, response):
            """
            Optional MSGPACK response.
        
            Sets MSGPACK content type to given handler.
        Severity: Minor
        Found in tcrudge/response.py and 1 other location - About 35 mins to fix
        tcrudge/response.py on lines 16..29

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

            def qs_order_by(cls, qs, value, process_value=True):
                """
                Set ORDER BY part of response.
        
                Fields are passed in a string with commas to separate values.
        Severity: Minor
        Found in tcrudge/handlers.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