strigo/wryte

View on GitHub

Showing 10 of 16 total issues

File wryte.py has 415 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# pylint: disable=missing-docstring

# Copyright 2017-2018 Nir Cohen
#
# Licensed under the Apache License, Version 2.0 (the "License");
Severity: Minor
Found in wryte.py - About 5 hrs to fix

    Wryte has 26 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Wryte:
        def __init__(
            self,
            name=None,
            hostname=None,
    Severity: Minor
    Found in wryte.py - About 3 hrs to fix

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

          def __init__(
      Severity: Major
      Found in wryte.py - About 1 hr to fix

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

            def main(level, message, objects, pretty, jsonify, name, no_color, simple):
        Severity: Major
        Found in wryte.py - About 1 hr to fix

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

              def main(level, message, objects, pretty, jsonify, name, no_color, simple):
                  wryter = Wryte(name=name, pretty=pretty, level=level, jsonify=jsonify, color=not no_color, simple=simple)
          
                  objcts = []
          
          
          Severity: Minor
          Found in wryte.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 add_handler has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_handler(self, handler, name=None, formatter='json', level='info'):
                  """Add a handler to the logger instance and return its name.
          
                  A `handler` can be any standard `logging` handler.
                  `formatter` can be one of `console`, `json` or a formatter instance.
          Severity: Minor
          Found in wryte.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

          Function format has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def format(self, record):
                  """Formats the message to be human readable
          
                  This formatter receives a dictionary as `msg`. It then removes
                  irrelevant fields and declare generates a string that looks like so:
          Severity: Minor
          Found in wryte.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

          Function _normalize_objects has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def _normalize_objects(objects):
                  """Return a normalized dictionary for a list of key value like objects.
          
                  This supports parsing dicts, json strings and key=value pairs.
          
          
          Severity: Minor
          Found in wryte.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

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

              def _get_base(self, name, hostname, enable_ec2=False):
                  """Generate base fields for each log message.
          
                  This is evaluated once when the logger's instance is instantiated.
                  It is then later copied by each log message.
          Severity: Minor
          Found in wryte.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 add_file_handler has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def add_file_handler(self):
                  if not self._env('HANDLERS_FILE_PATH'):
                      self.logger.warning('File handler file path not set')
                      return
          
          
          Severity: Minor
          Found in wryte.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