thoth-station/thamos

View on GitHub
thamos/config.py

Summary

Maintainability
D
2 days
Test Coverage

File config.py has 687 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: Major
Found in thamos/config.py - About 1 day to fix

Function get_runtime_environment has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def get_runtime_environment(self, name: Optional[str] = None) -> Dict[str, Any]:
        """Get runtime environment, retrieve the first runtime environment (the default one) if no name is provided."""
        content = self.content
        if "runtime_environments" not in content:
            raise NoRuntimeEnvironmentError(
Severity: Minor
Found in thamos/config.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 create_default_config has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def create_default_config(
        self, template: Optional[str] = None, nowrite: bool = False
    ) -> Optional[dict]:
        """Place default configuration into the current directory."""
        if not os.path.isdir(".git"):
Severity: Minor
Found in thamos/config.py - About 1 hr to fix

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

    def create_default_config(
        self, template: Optional[str] = None, nowrite: bool = False
    ) -> Optional[dict]:
        """Place default configuration into the current directory."""
        if not os.path.isdir(".git"):
Severity: Minor
Found in thamos/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

Function api_discovery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def api_discovery(self, host: str) -> str:
        """Discover API versions available, return the most recent one supported by client and server."""
        api_url = urljoin("https://" + host, "api/v1")
        self.tls_verify = (
            self.tls_verify
Severity: Minor
Found in thamos/config.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 check_runtime_environment has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def check_runtime_environment(
        self, runtime_environment_name: str
    ) -> List[Dict[str, Any]]:
        """Check the given runtime environment entry."""
        runtime_environment = self.get_runtime_environment(runtime_environment_name)
Severity: Minor
Found in thamos/config.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