getindata/kedro-airflow-k8s

View on GitHub
kedro_airflow_k8s/operators/start_mlflow_experiment.py

Summary

Maintainability
A
1 hr
Test Coverage
C
74%

Function __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Minor
Found in kedro_airflow_k8s/operators/start_mlflow_experiment.py - About 45 mins to fix

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

        def execute(self, context: Dict):
            """
            On pipeline start it may be required to create experiment if it does not exist
            which happens in this method. Obtains experiment run_id and passes to xcom as
             `mlflow_run_id` so it can be referenced by ML related tasks.
    Severity: Minor
    Found in kedro_airflow_k8s/operators/start_mlflow_experiment.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

    Too few public methods (1/2)
    Open

    class VarsAuthHandler(AuthHandler):

    Used when class has too few public methods, so be sure it's really worth it.

    Too few public methods (1/2)
    Open

    class AuthHandler:

    Used when class has too few public methods, so be sure it's really worth it.

    Either all return statements in a function should return an expression, or none of them should.
    Open

        def obtain_credentials(self) -> Dict[str, str]:

    According to PEP8, if any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable)

    Too few public methods (1/2)
    Open

    class GoogleOAuth2AuthHandler(AuthHandler):

    Used when class has too few public methods, so be sure it's really worth it.

    Too many arguments (6/5)
    Open

        def __init__(

    Used when a function or method takes too many arguments.

    Specify string format arguments as logging function parameters
    Open

                    self.log.error("Failed to obtain IAP access token. " + str(e))

    Used when a logging statement has a call form of logging.<logging method>(format_string % (format_args...)). Such calls should leave string interpolation to the logging method itself and be written logging.<logging method>(format_string, format_args...) so that the program may avoid incurring the cost of the interpolation in those cases in which no message will be logged. For more, see http://www.python.org/dev/peps/pep-0282/.

    Catching too general exception Exception
    Open

                except Exception as e:

    Used when an except catches a too general exception, possibly burying unrelated errors.

    return statement in finally block may swallow exception
    Open

                    return {"MLFLOW_TRACKING_TOKEN": token}

    Used when a break or a return statement is found inside the finally clause of a try...finally block: the exceptions raised in the try clause will be silently swallowed instead of being re-raised.

    Specify string format arguments as logging function parameters
    Open

                    self.log.debug(

    Used when a logging statement has a call form of logging.<logging method>(format_string % (format_args...)). Such calls should leave string interpolation to the logging method itself and be written logging.<logging method>(format_string, format_args...) so that the program may avoid incurring the cost of the interpolation in those cases in which no message will be logged. For more, see http://www.python.org/dev/peps/pep-0282/.

    Missing class docstring
    Open

    class VarsAuthHandler(AuthHandler):

    Used when a class has no docstring.Even an empty class must have a docstring.

    Missing function or method docstring
    Open

        def instance():

    Used when a function or method has no docstring.Some special methods like init do not require a docstring.

    Variable name e doesn't conform to snake_case naming style
    Open

                except Exception as e:

    Used when the name doesn't conform to naming rules associated to its type (constant, variable, class...).

    Missing class docstring
    Open

    class NullAuthHandler(AuthHandler):

    Used when a class has no docstring.Even an empty class must have a docstring.

    Missing class docstring
    Open

    class GoogleOAuth2AuthHandler(AuthHandler):

    Used when a class has no docstring.Even an empty class must have a docstring.

    Missing class docstring
    Open

    class AuthHandler:

    Used when a class has no docstring.Even an empty class must have a docstring.

    Missing function or method docstring
    Open

        def obtain_credentials(self) -> Dict[str, str]:

    Used when a function or method has no docstring.Some special methods like init do not require a docstring.

    There are no issues that match your filters.

    Category
    Status