cocaine/cocaine-framework-python

View on GitHub
cocaine/detail/logger.py

Summary

Maintainability
C
1 day
Test Coverage

Function resolve_logging has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def resolve_logging(endpoints, name="logging", io_loop=None):
    if io_loop:
        warnings.warn('io_loop argument is deprecated.', DeprecationWarning)

    for host, port in endpoints:
Severity: Minor
Found in cocaine/detail/logger.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 _send has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    def _send(self):
        """ Send a message lazy formatted with args.
        External log attributes can be passed via named attribute `extra`,
        like in logging from the standart library.

Severity: Minor
Found in cocaine/detail/logger.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 emit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def emit(self, record):
        lvl = record.levelno
        extra = getattr(record, "extra", {})
        if lvl >= logging.ERROR:
            # to avoid message formatting
Severity: Minor
Found in cocaine/detail/logger.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 makeRecord has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):  # noqa
Severity: Major
Found in cocaine/detail/logger.py - About 1 hr to fix

    Function prepare_message_args has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def prepare_message_args(self, level, message, *args, **kwargs):
            if args:
                try:
                    message %= args
                except Exception:
    Severity: Minor
    Found in cocaine/detail/logger.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 update_verbosity has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def update_verbosity(self):
            counter = next(self.counter)
            verbosity_request = msgpack_packb([counter, VERBOSITY, []])
            self.pipe.write(verbosity_request)
            buff = msgpack_unpacker()
    Severity: Minor
    Found in cocaine/detail/logger.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

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

        @property
        def _connected(self):
            return self.pipe is not None and not self.pipe.closed()
    Severity: Minor
    Found in cocaine/detail/logger.py and 1 other location - About 40 mins to fix
    cocaine/detail/baseservice.py on lines 258..260

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

            elif lvl >= logging.WARNING:
                if self._logger.enable_for(WARNING_LEVEL):
                    self._logger.warning(self.format(record), extra=extra)
    Severity: Major
    Found in cocaine/detail/logger.py and 3 other locations - About 35 mins to fix
    cocaine/detail/logger.py on lines 309..312
    cocaine/detail/logger.py on lines 316..318
    cocaine/detail/logger.py on lines 319..321

    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

            elif lvl >= logging.DEBUG:
                if self._logger.enable_for(DEBUG_LEVEL):
                    self._logger.debug(self.format(record), extra=extra)
    Severity: Major
    Found in cocaine/detail/logger.py and 3 other locations - About 35 mins to fix
    cocaine/detail/logger.py on lines 309..312
    cocaine/detail/logger.py on lines 313..315
    cocaine/detail/logger.py on lines 316..318

    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

            if lvl >= logging.ERROR:
                # to avoid message formatting
                if self._logger.enable_for(ERROR_LEVEL):
                    self._logger.error(self.format(record), extra=extra)
    Severity: Major
    Found in cocaine/detail/logger.py and 3 other locations - About 35 mins to fix
    cocaine/detail/logger.py on lines 313..315
    cocaine/detail/logger.py on lines 316..318
    cocaine/detail/logger.py on lines 319..321

    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

            elif lvl >= logging.INFO:
                if self._logger.enable_for(INFO_LEVEL):
                    self._logger.info(self.format(record), extra=extra)
    Severity: Major
    Found in cocaine/detail/logger.py and 3 other locations - About 35 mins to fix
    cocaine/detail/logger.py on lines 309..312
    cocaine/detail/logger.py on lines 313..315
    cocaine/detail/logger.py on lines 319..321

    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

    There are no issues that match your filters.

    Category
    Status