Showing 18 of 18 total issues
Method scaffold
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def scaffold
# puts "args #{self.args}"
# puts "options #{self.options}"
puts "behavior #{self.behavior}"
# puts "shell #{self.shell}"
- 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 attributes_to_aa_index(attributes)
attributes.map do |attr|
case attr.type
when :references, :belongs_to then " # column(:#{attr.name})"
when :boolean then " # column(:#{attr.name})#{' ' * (ACTIVEADMIN_INDENT_SPACES-attr.name.size).abs}{|#{singular_table_name}| status_tag #{singular_table_name}.#{attr.name}}"
- 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 73.
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 attributes_to_aa_show(attributes)
attributes.map do |attr|
case attr.type
when :references, :belongs_to then " # row(:#{attr.name})"
when :boolean then " # row(:#{attr.name})#{' ' * (ACTIVEADMIN_INDENT_SPACES-attr.name.size).abs}{|#{singular_table_name}| status_tag #{singular_table_name}.#{attr.name}}"
- 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 73.
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 item
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def item(options={})
#:search => {:id => 3}
#:get => :name
options = {
:search => 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 setup_authentication
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_authentication
file = "app/models/#{options[:auth_class].downcase}.rb"
#puts "File #{file} #{File.exists?(file) ? "" : "does not"} exists!"
return unless options.authentication? and File.exists?(file)
Method create_users_for_development
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def create_users_for_development
return unless options.authentication?
file = "db/seeds.rb"
# Remove devise default user
gsub_file file, /User\.create!\(.+\)/, "" if File.exists?(file)
- 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 setup_application
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_application
application do
<<-FILE.gsub(/^ /, '')
config.generators do |g|
Method generate_layout
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def generate_layout
template "styles/#{style_name}/stylesheets/app/stylesheet.scss.erb", "app/assets/stylesheets/#{style_name}.scss.erb"
template "styles/#{style_name}/stylesheets/app/custom_active_admin.scss.erb", "app/assets/stylesheets/custom_active_admin.scss.erb"
template "styles/#{style_name}/stylesheets/app/_production.scss", "app/assets/stylesheets/_production.scss"
- 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 scaffold
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def scaffold
# puts "args #{self.args}"
# puts "options #{self.options}"
puts "behavior #{self.behavior}"
# puts "shell #{self.shell}"
Method setup_rspec
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_rspec
file = "spec/spec_helper.rb"
return unless File.exists?(file) && options.rspec?
inject_into_file file, :after => "require 'rspec/rails'" do
<<-FILE.gsub(/^ /, '')
Method setup_activeadmin
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup_activeadmin
return unless options.activeadmin? and activeadmin?
template "config/initializers/activeadmin_leonardo.rb", "config/initializers/activeadmin_leonardo.rb"
#copy_file "config/initializers/activeadmin_cancan.rb", "config/initializers/activeadmin_cancan.rb" if options.authorization?
#template "app/admin/users.rb", "app/admin/#{options[:auth_class].downcase.pluralize}.rb"
Method generate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def generate line
regexp_rails_g = 'rails [dg][a-z]*\s'
line.strip!
unless line.empty? or line[0..0]=="#"
if /#{regexp_rails_g}/i === line
- 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 invoke_active_admin
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def invoke_active_admin
return unless activeadmin? && options[:activeadmin]
invoke "active_admin:resource", [singular_table_name]
file = "app/admin/#{singular_table_name}.rb"
- 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 get_attr_to_check
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_attr_to_check(view=:list)
case view
when :something
else
attributes.each{|a| case a.type when :string, :text then return a.name end}
- 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 3 locations. Consider refactoring. Open
def generate_routing_spec
return unless options[:routing_specs]
template 'routing_spec.rb',
#File.join('spec/routing', base_namespaces, controller_class_path, "#{controller_file_name}_routing_spec.rb")
- 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 35.
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 3 locations. Consider refactoring. Open
def generate_request_spec
return unless options[:request_specs]
template 'feature.rb',
#File.join('spec/requests', class_path, base_namespaces, "#{table_name}_spec.rb")
- 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 35.
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 3 locations. Consider refactoring. Open
def generate_controller_spec
return unless options[:controller_specs]
template 'controller_spec.rb',
#File.join('spec/controllers', base_namespaces, controller_class_path, "#{controller_file_name}_controller_spec.rb")
- 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 35.
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 add_seeds_db
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def add_seeds_db
return unless options.seeds? and options[:seeds_elements].to_i > 0
file = "db/seeds.rb"
append_file file do
items = []
- 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"