thoth-station/thamos

View on GitHub
thamos/discover.py

Summary

Maintainability
C
1 day
Test Coverage

Function discover_cudnn_version has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

def discover_cudnn_version() -> Optional[str]:
    """Discover CuDNN version and return None if not found."""
    result = run_command("nvcc --version", raise_on_error=False)

    if result.return_code != 0:
Severity: Minor
Found in thamos/discover.py - About 4 hrs 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

File discover.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# thamos
# Copyright(C) 2018 - 2021 Fridolin Pokorny
#
# This program is free software: you can redistribute it and / or modify
Severity: Minor
Found in thamos/discover.py - About 2 hrs to fix

Function discover_cpu has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Confirmed

def discover_cpu() -> Dict[str, Union[str, int, None]]:
    """Discover CPU model, model name and family."""
    result = {
        "cpu_family": None,
        "cpu_model": None,
Severity: Minor
Found in thamos/discover.py - About 2 hrs 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 discover_rpm_package has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def discover_rpm_package(package_name: str) -> Optional[Dict[str, str]]:
    """Check for version of a RPM package and return None if not found."""
    result = run_command(f"rpm -qa | grep {package_name}", raise_on_error=False)

    if result.return_code != 0:
Severity: Minor
Found in thamos/discover.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 discover_base_image has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def discover_base_image() -> Optional[str]:
    """Discover base image and its version."""
    # IMAGE_NAME and IMAGE_TAG injected by AICoE-CI take precedence over Thoth s2i.
    base_image_name = os.getenv("IMAGE_NAME", os.getenv("THOTH_S2I_NAME"))
    base_image_version = os.getenv("IMAGE_TAG")
Severity: Minor
Found in thamos/discover.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

There are no issues that match your filters.

Category
Status