sammcj/scripts

View on GitHub

Showing 49 of 129 total issues

File bear_export_sync.py has 540 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
# encoding=utf-8
# python3.6
# bear_export_sync.py
# Developed with Visual Studio Code with MS Python Extension.
Severity: Major
Found in bear_export_sync.py - About 1 day to fix

    File bear_export_sync.py has 538 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # encoding=utf-8
    # python3.6
    # bear_export_sync.py
    # Developed with Visual Studio Code with MS Python Extension.
    
    
    Severity: Major
    Found in bear/bear_export_sync.py - About 1 day to fix

      Function main has a Cognitive Complexity of 59 (exceeds 20 allowed). Consider refactoring.
      Open

      func main() {
          if listAllFans {
              // List all fans and exit
              os.Exit(0)
          }
      Severity: Minor
      Found in nvidia/nv_fan_control.go - About 6 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 sub_path_from_tag has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

      def sub_path_from_tag(temp_path, filename, md_text):
          # Get tags in note:
          pattern1 = r'(?<!\S)\#([.\w\/\-]+)[ \n]?(?!([\/ \w]+\w[#]))'
          pattern2 = r'(?<![\S])\#([^ \d][.\w\/ ]+?)\#([ \n]|$)'
          if multi_tag_folders:
      Severity: Minor
      Found in bear/bear_export_sync.py - About 6 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 sub_path_from_tag has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
      Open

      def sub_path_from_tag(temp_path, filename, md_text):
          # Get tags in note:
          # pattern1 = r'(?<!\S)\#([.\w\/\-]+)[ \n]?(?!([\/ \w]+\w[#]))' # Tags without spaces
          # the same as above, but ignores tags less than 3 characters long and tags that don't start with a letter
          pattern1 = r'(?<!\S)\#([a-zA-Z][.\w\/\-]{2,})[ \n]?(?!([\/ \w]+\w[#]))'
      Severity: Minor
      Found in bear_export_sync.py - About 6 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 main has 136 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func main() {
          if listAllFans {
              // List all fans and exit
              os.Exit(0)
          }
      Severity: Major
      Found in nvidia/nv_fan_control.go - About 4 hrs to fix

        Function printOutput has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        def printOutput(stats):
            """
            Print statistics output with or without Curses
            """
            head = " Average statistics, interval %s seconds " % args.interval
        Severity: Minor
        Found in OLD/gluster/glustertop.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

        Function main has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
        Open

        def main():
            """
            Main entrance
             * get stats in the loop
            """
        Severity: Minor
        Found in OLD/gluster/glustertop.py - About 3 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 sync_md_updates has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        def sync_md_updates():
            updates_found = False
            if not os.path.exists(sync_ts_file) or not os.path.exists(export_ts_file):
                return False
            ts_last_sync = os.path.getmtime(sync_ts_file)
        Severity: Minor
        Found in bear_export_sync.py - About 3 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 sync_md_updates has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        def sync_md_updates():
            updates_found = False
            if not os.path.exists(sync_ts_file) or not os.path.exists(export_ts_file):
                return False
            ts_last_sync = os.path.getmtime(sync_ts_file)
        Severity: Minor
        Found in bear/bear_export_sync.py - About 3 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 move_to_root_folder has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        def move_to_root_folder(root_path, cur_path):
            for filename in os.listdir(cur_path):
                if os.path.isfile(os.path.join(cur_path, filename)):
                    # if the file already exists, overwrite it
                    if os.path.isfile(os.path.join(root_path, filename)):
        Severity: Minor
        Found in obsidian-bear-import.py - About 3 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 export_markdown has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        def export_markdown():
            with sqlite3.connect(bear_db) as conn:
                conn.row_factory = sqlite3.Row
                query = "SELECT * FROM `ZSFNOTE` WHERE `ZTRASHED` LIKE '0' AND `ZARCHIVED` LIKE '0'"
                c = conn.execute(query)
        Severity: Minor
        Found in bear_export_sync.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 export_markdown has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

        def export_markdown():
            with sqlite3.connect(bear_db) as conn:
                conn.row_factory = sqlite3.Row
                query = "SELECT * FROM `ZSFNOTE` WHERE `ZTRASHED` LIKE '0' AND `ZARCHIVED` LIKE '0'"
                c = conn.execute(query)
        Severity: Minor
        Found in bear/bear_export_sync.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 init has 97 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func init() {
            // Initialize the logger
            logger = log.New(os.Stdout, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)
        
            flag.StringVar(&fanPath, "fanpath", "/sys/class/hwmon/hwmon4/pwm3", "Path to the PWM fan control")
        Severity: Major
        Found in nvidia/nv_fan_control.go - About 2 hrs to fix

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

          def select_calendar(prompt, default_calendar=None, match_string=None):
              script = """
              tell application "Calendar"
                  set matchingCalendars to {}
                  set calendarNames to {{}}
          Severity: Minor
          Found in calendar/move-calendar-items.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

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

          #!/usr/bin/env python
          
          """
          Display gluster traffic
          This tool uses gluster profiling feature, parsing cumulative statistics.
          Severity: Minor
          Found in OLD/gluster/glustertop.py - About 2 hrs to fix

            Function move_files has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
            Open

            def move_files(src_dir, dest_dir, dry_run=False):
              """Move all files from src_dir and its subdirectories to dest_dir, renaming
              them to ensure that no two files have the same name. Returns a mapping of
              old file names to new file names. If dry_run is True, the files will not
              actually be moved.
            Severity: Minor
            Found in refactor_md_image_dirs.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

            File nv_fan_control.go has 503 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            // A simple tool that adjusts the fan speed of the GPU based on its temperature.
            // Its designed for a custom cooler I have on my Nvidia Tesla P100 which is a 12v non-pwm fan.
            // Author: Sam McLeod @sammcj
            package main
            
            
            Severity: Minor
            Found in nvidia/nv_fan_control.go - About 2 hrs to fix

              Function update_markdown_links has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

              def update_markdown_links(markdown_dir, src_dir, dest_dir, file_mapping, strip_full_path=True, dry_run=False):
                """Update all image links in markdown files in markdown_dir (recursively)
                using the provided file mapping. If dry_run is True, the links will not
                actually be updated.
                """
              Severity: Minor
              Found in refactor_md_image_dirs.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

              Function get_tag_from_path has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_tag_from_path(md_text, md_file, root_path, inbox_for_root=True, extra_tag=''):
                  # extra_tag should be passed as '#tag' or '#space tag#'
                  path = md_file.replace(root_path, '')[1:]
                  sub_path = os.path.split(path)[0]
                  tags = []
              Severity: Minor
              Found in bear_export_sync.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

              Severity
              Category
              Status
              Source
              Language