mardiros/blacksmith

View on GitHub

Showing 36 of 36 total issues

File route_proxy.py has 374 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from typing import Any, Dict, Generic, List, Mapping, Optional, Tuple, Type, Union

try:
    from types import UnionType  # type: ignore
except ImportError:  # coverage: ignore
Severity: Minor
Found in src/blacksmith/service/_async/route_proxy.py - About 5 hrs to fix

    File route_proxy.py has 360 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from typing import Any, Dict, Generic, List, Mapping, Optional, Tuple, Type, Union
    
    try:
        from types import UnionType  # type: ignore
    except ImportError:  # coverage: ignore
    Severity: Minor
    Found in src/blacksmith/service/_sync/route_proxy.py - About 4 hrs to fix

      File params.py has 317 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import abc
      import warnings
      from dataclasses import dataclass
      from functools import partial
      from typing import (
      Severity: Minor
      Found in src/blacksmith/domain/model/params.py - About 3 hrs to fix

        ResponseBox has 23 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class ResponseBox(Generic[TResponse, TError_co]):
            """
            Wrap a HTTP response and deserialize it.
        
            ::
        Severity: Minor
        Found in src/blacksmith/domain/model/params.py - About 2 hrs to fix

          SyncRouteProxy has 22 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class SyncRouteProxy(Generic[TCollectionResponse, TResponse, TError_co]):
              """Proxy from resource to its associate routes."""
          
              client_name: ClientName
              name: ResourceName
          Severity: Minor
          Found in src/blacksmith/service/_sync/route_proxy.py - About 2 hrs to fix

            Function serialize_response has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            def serialize_response(resp: HTTPRawResponse) -> HTTPResponse:
                """
                Deserialize an http response to the http intermediate representation that will
                become the pydantic based response.
                Basically it parse json bytes a a python structure. But this function is here
            Severity: Minor
            Found in src/blacksmith/service/http_body_serializer.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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def __init__(
            Severity: Major
            Found in src/blacksmith/service/_sync/route_proxy.py - About 1 hr to fix

              Function register has 9 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              def register(
              Severity: Major
              Found in src/blacksmith/domain/registry.py - About 1 hr to fix

                Function register has 9 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def register(
                Severity: Major
                Found in src/blacksmith/domain/registry.py - About 1 hr to fix

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

                      def __init__(
                  Severity: Major
                  Found in src/blacksmith/service/_async/route_proxy.py - About 1 hr to fix

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

                    Severity: Major
                    Found in src/blacksmith/middleware/_sync/__init__.py and 1 other location - About 1 hr to fix
                    src/blacksmith/middleware/_async/__init__.py on lines 0..18

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

                    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

                    Severity: Major
                    Found in src/blacksmith/middleware/_async/__init__.py and 1 other location - About 1 hr to fix
                    src/blacksmith/middleware/_sync/__init__.py on lines 0..18

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

                    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 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(
                    Severity: Major
                    Found in src/blacksmith/service/_async/client.py - About 1 hr to fix

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

                          def __init__(
                      Severity: Major
                      Found in src/blacksmith/service/_sync/client.py - About 1 hr to fix

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

                            def __init__(
                        Severity: Major
                        Found in src/blacksmith/service/_async/client.py - About 1 hr to fix

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

                              def __init__(
                          Severity: Major
                          Found in src/blacksmith/service/_sync/client.py - About 1 hr to fix

                            Function build_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def build_request(typ: Type[Any], params: Mapping[str, Any]) -> Request:
                                if is_union(typ):
                                    err: Optional[Exception] = None
                                    for t in typ.__args__:  # type: ignore
                                        try:
                            Severity: Minor
                            Found in src/blacksmith/service/_async/route_proxy.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 build_request has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def build_request(typ: Type[Any], params: Mapping[str, Any]) -> Request:
                                if is_union(typ):
                                    err: Optional[Exception] = None
                                    for t in typ.__args__:  # type: ignore
                                        try:
                            Severity: Minor
                            Found in src/blacksmith/service/_sync/route_proxy.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 parse_header_links has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                            def parse_header_links(value: str) -> List[Dict[str, str]]:
                                """
                                Returns a list of parsed link headers, for more info see:
                                https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link
                            
                            
                            Severity: Minor
                            Found in src/blacksmith/domain/model/http.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def __init__(
                            Severity: Major
                            Found in src/blacksmith/sd/_async/adapters/consul.py - About 50 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language