benjaminoakes/maid

View on GitHub

Showing 11 of 16 total issues

File tools.rb has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'digest/sha1'
require 'find'
require 'fileutils'
require 'time'

Severity: Minor
Found in lib/maid/tools.rb - About 6 hrs to fix

    Method sync has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def sync(from, to, options = {})
        # expand removes trailing slash
        # cannot use str[-1] due to ruby 1.8.7 restriction
        from = expand(from) + (from.end_with?('/') ? '/' : '')
        to = expand(to) + (to.end_with?('/') ? '/' : '')
    Severity: Minor
    Found in lib/maid/tools.rb - 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

    Method migrate_trash has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def migrate_trash
        migration = Maid::TrashMigration
        banner('Trash Migration', :yellow)
    
        say <<~EOF
    Severity: Minor
    Found in lib/maid/app.rb - About 1 hr to fix

      Method trash has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

        def trash(paths, options = {})
          # ## Implementation Notes
          #
          # Trashing files correctly is surprisingly hard.  What Maid ends up doing
          # is one the easiest, most foolproof solutions:  moving the file.
      Severity: Minor
      Found in lib/maid/tools.rb - About 55 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

      Method has_been_used? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def has_been_used?(path)
          if Maid::Platform.osx?
            path = expand(path)
            raw = cmd("mdls -raw -name kMDItemLastUsedDate #{sh_escape(path)}")
      
      
      Severity: Minor
      Found in lib/maid/tools.rb - About 45 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

      Method used_at has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def used_at(path)
          if Maid::Platform.osx?
            path = expand(path)
            raw = cmd("mdls -raw -name kMDItemLastUsedDate #{sh_escape(path)}")
      
      
      Severity: Minor
      Found in lib/maid/tools.rb - About 45 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

      Method added_at has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def added_at(path)
          if Maid::Platform.osx?
            path = expand(path)
            raw = cmd("mdls -raw -name kMDItemDateAdded #{sh_escape(path)}")
      
      
      Severity: Minor
      Found in lib/maid/tools.rb - About 45 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

      Method maid_options has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def maid_options(options)
            h = {}
      
            if options['noop']
              # You're testing, so a simple log goes to STDOUT and no actions are taken
      Severity: Minor
      Found in lib/maid/app.rb - About 45 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

      Method clean has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def clean
          maid = Maid::Maid.new(maid_options(options))
      
          unless options.noop? || options.force?
            warn 'Running "maid clean" without a flag is deprecated.  Please use "maid clean --noop" or "maid clean --force".'
      Severity: Minor
      Found in lib/maid/app.rb - 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

      Method logs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def logs
          maid = Maid::Maid.new(maid_options(options))
      
          if options.path?
            say maid.log_device
      Severity: Minor
      Found in lib/maid/app.rb - 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

      Method move has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        def move(sources, destination_dir, clobber: true)
          expanded_destination_dir = expand(destination_dir)
      
          if File.directory?(expanded_destination_dir)
            expand_all(sources).each do |source|
      Severity: Minor
      Found in lib/maid/tools.rb - 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