robbyrussell/oh-my-zsh

View on GitHub

Showing 12 of 12 total issues

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

import os
import subprocess
import sys
import requests
import shutil
Severity: Minor
Found in .github/workflows/dependencies/updater.py - About 3 hrs to fix

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

    def get_http_proxy():
        default_proxy = os.environ.get(proxy_env)
        no_proxy = os.environ.get(no_proxy_env)
        if default_proxy and no_proxy:
            return default_proxy, no_proxy
    Severity: Minor
    Found in plugins/shell-proxy/proxy.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 colored has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def colored(text, color=None, on_color=None, attrs=None):
        """Colorize text.
    
        Available text colors:
            red, green, yellow, blue, magenta, cyan, white.
    Severity: Minor
    Found in plugins/aliases/termcolor.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

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

    ATTRIBUTES = dict(
            list(zip([
                'bold',
                'dark',
                '',
    Severity: Major
    Found in plugins/aliases/termcolor.py and 2 other locations - About 50 mins to fix
    plugins/aliases/termcolor.py on lines 51..62
    plugins/aliases/termcolor.py on lines 67..78

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

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

    HIGHLIGHTS = dict(
            list(zip([
                'on_grey',
                'on_red',
                'on_green',
    Severity: Major
    Found in plugins/aliases/termcolor.py and 2 other locations - About 50 mins to fix
    plugins/aliases/termcolor.py on lines 34..45
    plugins/aliases/termcolor.py on lines 67..78

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

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

    COLORS = dict(
            list(zip([
                'grey',
                'red',
                'green',
    Severity: Major
    Found in plugins/aliases/termcolor.py and 2 other locations - About 50 mins to fix
    plugins/aliases/termcolor.py on lines 34..45
    plugins/aliases/termcolor.py on lines 51..62

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

    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 pretty_print_group has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def pretty_print_group(key, aliases, highlight=None, only_groupname=False):
        if len(aliases) == 0:
            return
        group_hl_formatter = lambda g, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'red') for part in ('[%s]' % g).split(hl)])
        alias_hl_formatter = lambda alias, hl: termcolor.colored(hl, 'yellow').join([termcolor.colored(part, 'green') for part in ('\t%s = %s' % alias[0:2]).split(hl)])
    Severity: Minor
    Found in plugins/aliases/cheatsheet.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

    Avoid deeply nested control flow statements.
    Open

                    for div in divergence.split(', '):
                        if 'ahead' in div:
                            ahead = int(div[len('ahead '):].strip())
                        elif 'behind' in div:
                            behind = int(div[len('behind '):].strip())
    Severity: Major
    Found in plugins/git-prompt/gitstatus.py - About 45 mins to fix

      Function cprint has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def cprint(text, color=None, on_color=None, attrs=None, **kwargs):
      Severity: Minor
      Found in plugins/aliases/termcolor.py - About 35 mins to fix

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

            def __init__(self, message, returncode, stage, stdout, stderr):
        Severity: Minor
        Found in .github/workflows/dependencies/updater.py - About 35 mins to fix

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

          def cheatsheet(lines):
              exps = [ parse(line) for line in lines ]
              exps.sort(key=lambda exp:exp[2])
              cheatsheet = {'_default': []}
              for key, group in itertools.groupby(exps, lambda exp:exp[2]):
          Severity: Minor
          Found in plugins/aliases/cheatsheet.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 pretty_print has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def pretty_print(cheatsheet, wfilter, group_list=None, groups_only=False):
              sorted_key = sorted(cheatsheet.keys())
              for key in sorted_key:
                  if group_list and key not in group_list:
                      continue
          Severity: Minor
          Found in plugins/aliases/cheatsheet.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

          Severity
          Category
          Status
          Source
          Language