pylhc/submitter

View on GitHub

Showing 13 of 32 total issues

Function check_sixtrack_output_data has a Cognitive Complexity of 68 (exceeds 5 allowed). Consider refactoring.
Open

def check_sixtrack_output_data(jobname: str, basedir: Path):
    """Presence checks for SixDesk tracking output data.

    This checks recursively all directories in `track`.
    Will be busy for a while.
Severity: Minor
Found in pylhc_submitter/sixdesk_tools/troubleshooting.py - About 1 day 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 write_bash has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def write_bash(
    job_df: DataFrame,
    output_dir: Path = None,
    executable: str = "madx",
    cmdline_arguments: dict = None,
Severity: Minor
Found in pylhc_submitter/submitter/htc_utils.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 convert_paths_in_dict_to_strings has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def convert_paths_in_dict_to_strings(dict_: dict) -> dict:
    """Converts all Paths in the dict to strings, including those in iterables."""
    dict_ = dict_.copy()
    for key, value in dict_.items():
        if isinstance(value, Path):
Severity: Minor
Found in pylhc_submitter/utils/iotools.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_stats_df has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def _create_stats_df(df: pd.DataFrame, parameter: str, global_index: Any = None) -> TfsDataFrame:
    """ Calculates the stats over a given parameter.
    Note: Could be refactored to use `group_by`.

    Args:
Severity: Minor
Found in pylhc_submitter/sixdesk_tools/post_process_da.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 remove_twiss_fail_check has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

def remove_twiss_fail_check(jobname: str, basedir: Path):
    """ Comments out the "Twiss fail" check from mad6t.sh """
    LOG.info("Applying twiss-fail hack.")
    for mad6t_path in (
        get_mad6t_mask_path(jobname, basedir),
Severity: Minor
Found in pylhc_submitter/sixdesk_tools/create_workspace.py - About 1 hr 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

Avoid deeply nested control flow statements.
Open

                    if not len(angle_dirs):
                        raise OSError(f"No angle-dirs present in {str(turn_dir)}.")
Severity: Major
Found in pylhc_submitter/sixdesk_tools/troubleshooting.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        for angle_dir in angle_dirs:
                            if not angle_dir.is_dir():
                                continue
    
                            htcondor_files = list(angle_dir.glob("htcondor.*"))
    Severity: Major
    Found in pylhc_submitter/sixdesk_tools/troubleshooting.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not turn_dir.is_dir():
                              continue
      
      Severity: Major
      Found in pylhc_submitter/sixdesk_tools/troubleshooting.py - About 45 mins to fix

        Function write_bash has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def write_bash(
        Severity: Minor
        Found in pylhc_submitter/submitter/htc_utils.py - About 35 mins to fix

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

          def map_kwargs(add_dict: Dict[str, Any]) -> Dict[str, Any]:
              """
              Maps the kwargs for the job-file. 
              Some arguments have pre-defined choices and defaults, the remaining ones are just passed on.
          
          Severity: Minor
          Found in pylhc_submitter/submitter/htc_utils.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 _plot_seeds has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def _plot_seeds(ax, df_da: TfsDataFrame, da_col: str, interpolated: bool) -> Tuple[list, list]:
              """Add the Seed lines to the polar plots, if df_da is given.
          
              Args:
                  ax: Axes to plot in
          Severity: Minor
          Found in pylhc_submitter/sixdesk_tools/post_process_da.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 fix_pythonfile_call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def fix_pythonfile_call(jobname: str, basedir: Path):
              """ Removes '<' in the `binary file` line in mad6t.sh so __file__ works. """
              LOG.info("Applying python-file call fix.")
              for mad6t_path in (
                      get_mad6t_mask_path(jobname, basedir),
          Severity: Minor
          Found in pylhc_submitter/sixdesk_tools/create_workspace.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 submit_sixtrack has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def submit_sixtrack(jobname: str, basedir: Path, python: Path = None,
                              sixdesk: Path = SIXDESK_UTILS, ssh: str = None, resubmit: bool = False):
              """ Generate simulation files and check if runnable and submit. """
              re_str = "Re-" if resubmit else ""
              LOG.info(f"{re_str}Submitting to sixtrack.")
          Severity: Minor
          Found in pylhc_submitter/sixdesk_tools/submit.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

          Severity
          Category
          Status
          Source
          Language