iterative/dvc

View on GitHub
dvc/ignore.py

Summary

Maintainability
C
7 hrs
Test Coverage

File ignore.py has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import os
import re
from collections import namedtuple
from itertools import chain, groupby, takewhile
Severity: Minor
Found in dvc/ignore.py - About 4 hrs to fix

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

        def _update(
            self,
            dirname: str,
            ignore_trie: Trie,
            dnames: Optional["List"],
    Severity: Minor
    Found in dvc/ignore.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

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

        def _ignore_details(self, path, is_dir: bool):
            result = []
            for (regex, _), pattern_info in list(
                zip(self.regex_pattern_list, self.pattern_list)
            ):
    Severity: Minor
    Found in dvc/ignore.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 find has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def find(self, fs: FileSystem, path: AnyFSPath, **kwargs):
            if fs.protocol == Schemes.LOCAL:
                for root, _, files in self.walk(fs, path, **kwargs):
                    for file in files:
                        # NOTE: os.path.join is ~5.5 times slower
    Severity: Minor
    Found in dvc/ignore.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 check_ignore has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def check_ignore(self, target):
            # NOTE: can only be used in `dvc check-ignore`, see
            # https://github.com/iterative/dvc/issues/5046
            full_target = self.fs.path.abspath(target)
            if not self._outside_repo(full_target):
    Severity: Minor
    Found in dvc/ignore.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 _update_trie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _update_trie(self, dirname: str, trie: Trie) -> None:
            key = self._get_key(dirname)
            old_pattern = trie.longest_prefix(key).value
            matches = old_pattern.matches(dirname, DvcIgnore.DVCIGNORE_FILE, False)
    
    
    Severity: Minor
    Found in dvc/ignore.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_trie_pattern has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_trie_pattern(
            self, dirname, dnames: Optional["List"] = None, ignore_subrepos=True
        ) -> Optional["DvcIgnorePatterns"]:
            if ignore_subrepos:
                ignores_trie = self.ignores_trie_fs
    Severity: Minor
    Found in dvc/ignore.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

    There are no issues that match your filters.

    Category
    Status