stellargraph/stellargraph

View on GitHub
scripts/format_notebooks.py

Summary

Maintainability
B
4 hrs
Test Coverage

subprocess call - check for execution of untrusted input.
Open

                subprocess.run(
                    [
                        "buildkite-agent",
                        "annotate",
                        "--style=error",
Severity: Info
Found in scripts/format_notebooks.py by bandit

Starting a process with a partial executable path
Open

                subprocess.run(
                    [
                        "buildkite-agent",
                        "annotate",
                        "--style=error",
Severity: Info
Found in scripts/format_notebooks.py by bandit

Consider possible security implications associated with subprocess module.
Open

import subprocess
Severity: Info
Found in scripts/format_notebooks.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

        assert check_notebook, "things failed check without check being enabled"

Severity: Info
Found in scripts/format_notebooks.py by bandit

Use of exec detected.
Open

    exec(fh.read(), version)
Severity: Minor
Found in scripts/format_notebooks.py by bandit

Consider simplifying this complex logical expression.
Open

if __name__ == "__main__":

    parser = argparse.ArgumentParser(
        description="Format and clean Jupyter notebooks by removing TensorFlow warnings "
        "and stderr outputs, formatting and numbering the code cells, and setting the kernel. "
Severity: Critical
Found in scripts/format_notebooks.py - About 2 hrs to fix

    Avoid deeply nested control flow statements.
    Open

                    if original != updated:
                        check_failed.append(str(file_loc))
    
                        if on_ci:
                            # CI doesn't provide enough state to diagnose a peculiar or
    Severity: Major
    Found in scripts/format_notebooks.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      with open(file_loc) as f:
                          original = f.read()
      
      
      Severity: Major
      Found in scripts/format_notebooks.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                        with open(f"{nb_file_loc}.ipynb") as f:
                            updated = f.read()
        
        
        Severity: Major
        Found in scripts/format_notebooks.py - About 45 mins to fix

          Remove this commented out code.
          Open

              # html_exporter.template_file = 'basic'
          Severity: Major
          Found in scripts/format_notebooks.py by sonar-python

          Programmers should not comment out code as it bloats programs and reduces readability.

          Unused code should be deleted and can be retrieved from source control history if required.

          See

          • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
          • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
          • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
          • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

          There are no issues that match your filters.

          Category
          Status