iterative/dvc

View on GitHub

Showing 159 of 275 total issues

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

    def _drive(self):
        from pydrive2.auth import GoogleAuth
        from pydrive2.drive import GoogleDrive

        if os.getenv(GDriveRemote.GDRIVE_CREDENTIALS_DATA):
Severity: Minor
Found in dvc/remote/gdrive.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 run has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def run(self):
        indent = 1 if self.args.cloud else 0
        try:
            st = self.repo.status(
                targets=self.args.targets,
Severity: Minor
Found in dvc/command/status.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 show has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def show(
    repo,
    targets=None,
    all_branches=False,
    all_tags=False,
Severity: Minor
Found in dvc/repo/metrics/show.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 _read_metrics has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def _read_metrics(repo, metrics, rev):
    tree = RepoTree(repo)

    res = {}
    for metric in metrics:
Severity: Minor
Found in dvc/repo/metrics/show.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 17 locations. Consider refactoring.
Open

    init_parser = subparsers.add_parser(
        "init",
        parents=[parent_parser],
        description=append_doc_link(INIT_DESCRIPTION, "init"),
        help=INIT_HELP,
Severity: Major
Found in dvc/command/init.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    import_parser = subparsers.add_parser(
        "import-url",
        parents=[parent_parser],
        description=append_doc_link(IMPORT_HELP, "import-url"),
        help=IMPORT_HELP,
Severity: Major
Found in dvc/command/imp_url.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    checkout_parser = subparsers.add_parser(
        "checkout",
        parents=[parent_parser],
        description=append_doc_link(CHECKOUT_HELP, "checkout"),
        help=CHECKOUT_HELP,
Severity: Major
Found in dvc/command/checkout.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    params_parser = subparsers.add_parser(
        "params",
        parents=[parent_parser],
        description=append_doc_link(PARAMS_HELP, "params"),
        help=PARAMS_HELP,
Severity: Major
Found in dvc/command/params.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    def load(self):
        """Loads state database."""
        retries = 1
        while True:
            assert self.database is None
Severity: Minor
Found in dvc/state.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 17 locations. Consider refactoring.
Open

    move_parser = subparsers.add_parser(
        "move",
        parents=[parent_parser],
        description=append_doc_link(MOVE_DESCRIPTION, "move"),
        help=MOVE_HELP,
Severity: Major
Found in dvc/command/move.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    diff_parser = subparsers.add_parser(
        "diff",
        parents=[parent_parser],
        description=append_doc_link(DIFF_DESCRIPTION, "diff"),
        help=DIFF_DESCRIPTION,
Severity: Major
Found in dvc/command/diff.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    import_parser = subparsers.add_parser(
        "import",
        parents=[parent_parser],
        description=append_doc_link(IMPORT_HELP, "import"),
        help=IMPORT_HELP,
Severity: Major
Found in dvc/command/imp.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    def tree(self, tree):
        if is_working_tree(tree) or tree.tree_root == self.root_dir:
            root = None
        else:
            root = self.root_dir
Severity: Minor
Found in dvc/repo/__init__.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 git_object_by_path has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def git_object_by_path(self, path):
        import git

        path = relpath(os.path.realpath(path), self.git.working_dir)
        if path.split(os.sep, 1)[0] == "..":
Severity: Minor
Found in dvc/scm/git/tree.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 ByUrl has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def ByUrl(mapping):
    schemas = walk_values(Schema, mapping)

    def validate(data):
        if "url" not in data:
Severity: Minor
Found in dvc/config.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 17 locations. Consider refactoring.
Open

    params_diff_parser = params_subparsers.add_parser(
        "diff",
        parents=[parent_parser],
        description=append_doc_link(PARAMS_DIFF_HELP, "params/diff"),
        help=PARAMS_DIFF_HELP,
Severity: Major
Found in dvc/command/params.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    cache_parser = subparsers.add_parser(
        "cache",
        parents=[parent_parser],
        description=append_doc_link(CACHE_HELP, "cache"),
        help=CACHE_HELP,
Severity: Major
Found in dvc/command/cache.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/get.py on lines 54..59
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    def _walk(self, tree, topdown=True):
        dirs, nondirs = [], []
        for item in tree:
            name = _item_basename(item)
            if item.mode == GIT_MODE_DIR:
Severity: Minor
Found in dvc/scm/git/tree.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 17 locations. Consider refactoring.
Open

    get_parser = subparsers.add_parser(
        "get",
        parents=[parent_parser],
        description=append_doc_link(GET_HELP, "get"),
        help=GET_HELP,
Severity: Major
Found in dvc/command/get.py and 16 other locations - About 35 mins to fix
dvc/command/add.py on lines 32..37
dvc/command/cache.py on lines 19..24
dvc/command/checkout.py on lines 71..76
dvc/command/commit.py on lines 36..41
dvc/command/destroy.py on lines 37..42
dvc/command/diff.py on lines 137..142
dvc/command/gc.py on lines 68..73
dvc/command/imp.py on lines 35..40
dvc/command/imp_url.py on lines 32..37
dvc/command/init.py on lines 36..41
dvc/command/install.py on lines 21..26
dvc/command/move.py on lines 31..36
dvc/command/params.py on lines 60..65
dvc/command/params.py on lines 79..84
dvc/command/root.py on lines 20..25
dvc/command/update.py on lines 27..32

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

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

    def used_cache(
        self,
        targets=None,
        all_branches=False,
        with_deps=False,
Severity: Minor
Found in dvc/repo/__init__.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