Function with cyclomatic complexity higher than threshold PY-R1000
Anti-pattern
Minor
5 months ago5 months old
file_contents has a cyclomatic complexity of 165 with "critical" risk
142    trailing_commas: Set[str]
143
144
145def file_contents(contents: str, config: Config = DEFAULT_CONFIG) -> ParsedContent:146    """Parses a python file taking out and categorizing imports."""
147    line_separator: str = config.line_ending or _infer_line_separator(contents)
148    in_lines = contents.splitlines()
skip_line has a cyclomatic complexity of 18 with "high" risk
 79    return import_string.replace("{ ", "{|").replace(" }", "|}")
 80
 81
 82def skip_line( 83    line: str,
 84    in_quote: str,
 85    index: int,
line has a cyclomatic complexity of 30 with "very-high" risk
 68    return statement
 69
 70
 71def line(content: str, line_separator: str, config: Config = DEFAULT_CONFIG) -> str: 72    """Returns a line wrapped to the specified line-length, if possible."""
 73    wrap_mode = config.multi_line_output
 74    if len(content) > config.line_length and wrap_mode != Modes.NOQA:  # type: ignore
imports has a cyclomatic complexity of 47 with "very-high" risk
 39        )
 40
 41
 42def imports( 43    input_stream: TextIO,
 44    config: Config = DEFAULT_CONFIG,
 45    file_path: Optional[Path] = None,
_get_config_data has a cyclomatic complexity of 41 with "very-high" risk
829    return trie_root
830
831
832def _get_config_data(file_path: str, sections: Tuple[str, ...]) -> Dict[str, Any]:833    settings: Dict[str, Any] = {}
834
835    if file_path.endswith(".toml"):