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_
Class Pa
has 36 methods (exceeds 20 allowed). Consider refactoring. Open
class Pa
module Cmd
extend Util::Concern
DELEGATE_CLASS_METHODS = [ :home ]
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
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.
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) : "."
- Read upRead up
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]
- Read upRead up
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)}
- Read upRead up
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)
- Read upRead up
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 " : "")
- Read upRead up
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]
- Read upRead up
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]
- Read upRead up
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
- Read upRead up
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)
- Read upRead up
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|
- Read upRead up
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 }
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 }
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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)
- Read upRead up
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)
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) : "."
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 }
- Read upRead up
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"