nvbn/thefuck

View on GitHub

Showing 106 of 106 total issues

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

def get_valid_history_without_current(command):
    def _not_corrected(history, tf_alias):
        """Returns all lines from history except that comes before `fuck`."""
        previous = None
        for line in history:
Severity: Minor
Found in thefuck/utils.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

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

    def app_alias(self, alias_name):
        # It is VERY important to have the variables declared WITHIN the function
        return '''
            {name} () {{
                TF_PYTHONIOENCODING=$PYTHONIOENCODING;
Severity: Minor
Found in thefuck/shells/zsh.py and 1 other location - About 30 mins to fix
thefuck/shells/bash.py on lines 14..35

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

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

Avoid too many return statements within this function.
Open

            return val
Severity: Major
Found in thefuck/conf.py - About 30 mins to fix

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

    @git_support
    def match(command):
        return ('did not match any file(s) known to git' in command.output
                and "Did you forget to 'git add'?" not in command.output)
    Severity: Minor
    Found in thefuck/rules/git_checkout.py and 1 other location - About 30 mins to fix
    thefuck/rules/git_diff_staged.py on lines 5..8

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

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

    @git_support
    def match(command):
        return ('diff' in command.script and
                '--staged' not in command.script)
    Severity: Minor
    Found in thefuck/rules/git_diff_staged.py and 1 other location - About 30 mins to fix
    thefuck/rules/git_checkout.py on lines 9..12

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

    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

    Avoid too many return statements within this function.
    Open

            return None
    Severity: Major
    Found in thefuck/output_readers/read_log.py - About 30 mins to fix

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

          def app_alias(self, alias_name):
              # It is VERY important to have the variables declared WITHIN the function
              return '''
                  function {name} () {{
                      TF_PYTHONIOENCODING=$PYTHONIOENCODING;
      Severity: Minor
      Found in thefuck/shells/bash.py and 1 other location - About 30 mins to fix
      thefuck/shells/zsh.py on lines 15..38

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

      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

      Avoid too many return statements within this function.
      Open

                  return val.split(':')
      Severity: Major
      Found in thefuck/conf.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return url.scheme in ['http', 'https', 'ssh']
        Severity: Major
        Found in thefuck/rules/git_clone_missing.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return None
          Severity: Major
          Found in thefuck/output_readers/read_log.py - About 30 mins to fix

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

                    try:
                        self.update(self._settings_from_file())
                    except Exception:
                        exception("Can't load settings from file", sys.exc_info())
            Severity: Minor
            Found in thefuck/conf.py and 1 other location - About 30 mins to fix
            thefuck/conf.py on lines 39..42

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

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

                    try:
                        self.update(self._settings_from_env())
                    except Exception:
                        exception("Can't load settings from env", sys.exc_info())
            Severity: Minor
            Found in thefuck/conf.py and 1 other location - About 30 mins to fix
            thefuck/conf.py on lines 34..37

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

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

            def get_pkgfile(command):
                """ Gets the packages that provide the given command using `pkgfile`.
            
                If the command is of the form `sudo foo`, searches for the `foo` command
                instead.
            Severity: Minor
            Found in thefuck/specific/archlinux.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 read_actions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def read_actions():
                """Yields actions for pressed keys."""
                while True:
                    key = get_key()
            
            
            Severity: Minor
            Found in thefuck/ui.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 _tar_file has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def _tar_file(cmd):
                for c in cmd:
                    for ext in tar_extensions:
                        if c.endswith(ext):
                            return (c, c[0:len(c) - len(ext)])
            Severity: Minor
            Found in thefuck/rules/dirty_untar.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_alias has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def _get_alias(known_args):
                if six.PY2:
                    warn("The Fuck will drop Python 2 support soon, more details "
                         "https://github.com/nvbn/thefuck/issues/685")
            
            
            Severity: Minor
            Found in thefuck/entrypoints/alias.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_new_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_new_command(command):
                # If --set-upstream or -u are passed, remove it and its argument. This is
                # because the remaining arguments are concatenated onto the command suggested
                # by git, which includes --set-upstream and its argument
                command_parts = command.script_parts[:]
            Severity: Minor
            Found in thefuck/rules/git_push.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 main has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def main():
                """Shows useful information about how-to configure alias on a first run
                and configure automatically on a second.
            
                It'll be only visible when user type fuck and when alias isn't configured.
            Severity: Minor
            Found in thefuck/entrypoints/not_configured.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_scripts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            def get_scripts():
                """Get custom npm scripts."""
                proc = Popen(['npm', 'run-script'], stdout=PIPE)
                should_yeild = False
                for line in proc.stdout.readlines():
            Severity: Minor
            Found in thefuck/specific/npm.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 _val_from_env has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def _val_from_env(self, env, attr):
                    """Transforms env-strings to python."""
                    val = os.environ[env]
                    if attr in ('rules', 'exclude_rules'):
                        return self._rules_from_env(val)
            Severity: Minor
            Found in thefuck/conf.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