Showing 28 of 28 total issues

File cmd.rb has 405 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require "securerandom"

=begin
rm family
    * rm     _rm file only_
Severity: Minor
Found in lib/pa/cmd.rb - About 5 hrs to fix

    Class Pa has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class Pa
      module Cmd
        extend Util::Concern
    
        DELEGATE_CLASS_METHODS = [ :home ]
    Severity: Minor
    Found in lib/pa/cmd.rb - About 4 hrs to fix

      Class Pa has 34 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Pa 
        autoload :Util,    "pa/util"
        autoload :VERSION, "pa/version" 
      
          Error = Class.new Exception
      Severity: Minor
      Found in lib/pa.rb - About 4 hrs to fix

        File pa.rb has 331 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        require "pd"
        require "tmpdir"
        
        =begin rdoc
        Pa(Path) is similary to Pathname, but more powerful.
        Severity: Minor
        Found in lib/pa.rb - About 3 hrs to fix

          Method each2 has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
          Open

                def each2(*args, &blk) 
                  return Pa.to_enum(:each2, *args) unless blk
          
                  (dir,), o = Util.extract_options(args)
                  dir = dir ? get(dir) : "."
          Severity: Minor
          Found in lib/pa/directory.rb - 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

          Method _touch has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

                def _touch(paths, o)
                  o[:mode] ||= 0644
                  paths.map!{|v|get(v)}
                  extra_doc = o[:force] ? "-f " : nil
                  puts "touch #{extra_doc}#{paths.join(" ")}" if o[:show_cmd]
          Severity: Minor
          Found in lib/pa/cmd.rb - 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

          Method _mkdir has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                def _mkdir(paths, o)
                  puts "mkdir #{paths.join(" ")}" if o[:show_cmd]
          
                  o[:mode] ||= 0775
                  paths.map!{|v|get(v)}
          Severity: Minor
          Found in lib/pa/cmd.rb - 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

          Method _copy has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                def _copy(src, dest, o={})  
                  raise Errno::EEXIST, "dest exists -- #{dest}" if File.exists?(dest) and (not o[:force])
          
                  case type=File.ftype(src)
          
          
          Severity: Minor
          Found in lib/pa/cmd.rb - 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

          Method _ln has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
          Open

                def _ln(method, src_s, dest, o={})
                  srcs = Util.wrap_array(src_s)
                  dest = get(dest)
                  extra_doc = "" 
                  extra_doc << (method==:symlink ? "-s " : "")
          Severity: Minor
          Found in lib/pa/cmd.rb - 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

          Method rm has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def rm(*paths)
                  paths, o = Util.extract_options(paths)
                  extra_doc = o[:force] ? "-f " : nil
                  puts _wrap_cmd("rm #{extra_doc}#{paths.join(' ')}", o[:show_cmd]) if o[:show_cmd]
          
          
          Severity: Minor
          Found in lib/pa/cmd.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 empty_dir has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

                def empty_dir(*dirs)
                  dirs, o = Util.extract_options(dirs)
                  extra_doc = o[:force] ? "-f " : nil
                  puts _wrap_cmd("empty_dir #{extra_doc}#{dirs.join(" ")}", o[:show_cmd]) if o[:show_cmd]
          
          
          Severity: Minor
          Found in lib/pa/cmd.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 mv has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def mv(src_s, dest, o={}, &blk)
                  srcs = Util.wrap_array(src_s).map{|v| get(v)}
                  dest = get(dest)
          
                  extra_doc = o[:force] ? "-f " : nil
          Severity: Minor
          Found in lib/pa/cmd.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 _move has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def _move(src, dest, o)
                  raise Errno::EEXIST, "dest exists -- #{dest}" if File.exists?(dest) and (not o[:force])
          
                  # move same file.
                  return if File.absolute_path(src) == File.absolute_path(dest)
          Severity: Minor
          Found in lib/pa/cmd.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 rmdir has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

                def rmdir(*paths)
                  paths, o = Util.extract_options(paths)
                  extra_doc = o[:force] ? "-f " : nil
                  puts _wrap_cmd("rmdir #{extra_doc}#{paths.join(" ")}", o[:show_cmd]) if o[:show_cmd]
                  paths.each { |path|
          Severity: Minor
          Found in lib/pa/cmd.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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                def ls2_r(*args, &blk)
                  dirs, o = Util.extract_options(args)
                  dirs << "." if dirs.empty?
                  blk ||= proc { true }
          
          
          Severity: Major
          Found in lib/pa/directory.rb and 1 other location - About 1 hr to fix
          lib/pa/directory.rb on lines 214..230

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 57.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                def ls2(*args, &blk)
                  dirs, o = Util.extract_options(args)
                  dirs << "." if dirs.empty?
                  blk ||= proc { true }
          
          
          Severity: Major
          Found in lib/pa/directory.rb and 1 other location - About 1 hr to fix
          lib/pa/directory.rb on lines 247..262

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 57.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Method rm_r has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def rm_r(*paths)
                  paths, o = Util.extract_options(paths)
                  puts _wrap_cmd("rm -r #{paths.join(' ')}", o[:show_cmd]) if o[:show_cmd]
                  paths.each { |path|
                    pa = Pa(path)
          Severity: Minor
          Found in lib/pa/cmd.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 _copy has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def _copy(src, dest, o={})  
                  raise Errno::EEXIST, "dest exists -- #{dest}" if File.exists?(dest) and (not o[:force])
          
                  case type=File.ftype(src)
          
          
          Severity: Minor
          Found in lib/pa/cmd.rb - About 1 hr to fix

            Method each2 has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def each2(*args, &blk) 
                    return Pa.to_enum(:each2, *args) unless blk
            
                    (dir,), o = Util.extract_options(args)
                    dir = dir ? get(dir) : "."
            Severity: Minor
            Found in lib/pa/directory.rb - About 1 hr to fix

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

                    def ls2_r(*args, &blk)
                      dirs, o = Util.extract_options(args)
                      dirs << "." if dirs.empty?
                      blk ||= proc { true }
              
              
              Severity: Minor
              Found in lib/pa/directory.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

              Severity
              Category
              Status
              Source
              Language