tobi-wan-kenobi/bumblebee-status

View on GitHub
bumblebee_status/modules/contrib/arandr.py

Summary

Maintainability
B
4 hrs
Test Coverage
F
25%

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

    def popup(self, widget):
        """Create Popup that allows the user to control their displays in one
        of three ways: launch arandr, select a pre-set screenlayout, toggle a
        display.
        """
Severity: Minor
Found in bumblebee_status/modules/contrib/arandr.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_layouts has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def _get_layouts():
        """Loads and parses the arandr screen layout scripts."""
        layouts = {}
        try:
            for filename in os.listdir(__screenlayout_dir__):
Severity: Minor
Found in bumblebee_status/modules/contrib/arandr.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

Avoid deeply nested control flow statements.
Open

                            if "xrandr" not in s_line:
                                continue
                            displays_in_file = Module._parse_layout(line)
Severity: Major
Found in bumblebee_status/modules/contrib/arandr.py - About 45 mins to fix

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

    def _prune_layouts(layouts, displays):
        """Return a list of layouts whose displays are actually connected."""
        available = []
        for layout, needs in layouts.items():
            still_valid = True
Severity: Minor
Found in bumblebee_status/modules/contrib/arandr.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

There are no issues that match your filters.

Category
Status