Showing 7 of 25 total issues

Function send has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def send(self):
        from yeelight import Flow
        from yeelight import transitions
        bulb = self.get_bulb()
        state = self.state
Severity: Minor
Found in then/components/yeelight.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_body has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def update_body(self, body):
        if (self.content_type or body) and self.component.method not in CONTENT_TYPE_METHODS:
            raise ValidationError(
                'Error on {}: The body/content-type option only can be used with the {} methods.'.format(
                    self.component.name, ', '.join(CONTENT_TYPE_METHODS)
Severity: Minor
Found in then/components/http.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 get_template has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_template(self) -> TemplateBase:
        if self._use in self._templates:
            # TODO: use component_name for get the best template using params
            return self._templates[self._use][-1]
        template_name, component_name = self._get_use_name(default_template=False)
Severity: Minor
Found in then/helper.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

Avoid too many return statements within this function.
Open

        return self.default_template_class()
Severity: Major
Found in then/helper.py - About 30 mins to fix

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

        def get_next(self, on_end=None):
            if self._files is None:
                self._files = self.get_files()
            on_end = on_end or self.component._on_end
            try:
    Severity: Minor
    Found in then/components/command.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 message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def message(self, params=None, **kwargs):
            if params is None:
                params = Params()
            if isinstance(params, TemplateBase):
                params = params.args(**kwargs)
    Severity: Minor
    Found in then/components/base.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_component has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_component(self, use=None):
            use = use or self._use
            if not self.components:
                raise InvalidUsage('There are no configurations. Registers configs using '
                                   'Then(<component config>)')
    Severity: Minor
    Found in then/helper.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