File aspace_form_helper.rb
has 1009 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'mixed_content_parser'
module AspaceFormHelper
COMBOBOX_MIN_LIMIT = 50 # if a <select> has equal or more options than this value, output a combobox
Class FormContext
has 60 methods (exceeds 20 allowed). Consider refactoring. Open
class FormContext
def initialize(name, values_from, parent)
values = values_from.is_a?(JSONModelType) ? values_from.to_hash(:raw) : values_from
Method read_only_view
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
def read_only_view(hash, opts = {})
jsonmodel_type = hash["jsonmodel_type"]
schema = JSONModel(jsonmodel_type).schema
prefix = opts[:plugin] ? 'plugins.' : ''
html = "<div class='form-horizontal'>"
- 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 merge_victim_view
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def merge_victim_view(hash, opts = {})
jsonmodel_type = hash["jsonmodel_type"]
schema = JSONModel(jsonmodel_type).schema
prefix = opts[:plugin] ? 'plugins.' : ''
html = "<div class='form-horizontal'>"
- 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 slug_url_field
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def slug_url_field(name, repo_slug = nil, generate_url_with_repo_slug = nil)
url = ""
html = ""
case obj['jsonmodel_type']
Method label_with_field
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def label_with_field(name, field_html, opts = {})
opts[:label_opts] ||= {}
opts[:label_opts][:plugin] = opts[:plugin]
opts[:col_size] ||= 9
- 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 options_for
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def options_for(context, property, add_empty_options = false, opts = {})
options = []
options.push([(opts[:empty_label] || ""), ""]) if add_empty_options
defn = jsonmodel_schema_definition(property)
- 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 templates_for_js
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def templates_for_js(jsonmodel_type = nil)
@delivering_js_templates = true
result = ""
return result if @templates.blank?
Method read_only_view
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def read_only_view(hash, opts = {})
jsonmodel_type = hash["jsonmodel_type"]
schema = JSONModel(jsonmodel_type).schema
prefix = opts[:plugin] ? 'plugins.' : ''
html = "<div class='form-horizontal'>"
Method label_and_merge_select
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def label_and_merge_select(name, default = "", opts = {})
value = obj[name]
begin
jsonmodel_type = obj["jsonmodel_type"]
prefix = opts[:plugin] ? 'plugins.' : ''
- 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 checkboxes_for_oai_sets
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def checkboxes_for_oai_sets(set_json, value_list)
return "" if value_list == nil
# when called by #new, set_json will be nil.
if set_json
set_arry = JSON::parse(set_json)
Method label_with_field
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
def label_with_field(name, field_html, opts = {})
opts[:label_opts] ||= {}
opts[:label_opts][:plugin] = opts[:plugin]
opts[:col_size] ||= 9
Method merge_victim_view
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def merge_victim_view(hash, opts = {})
jsonmodel_type = hash["jsonmodel_type"]
schema = JSONModel(jsonmodel_type).schema
prefix = opts[:plugin] ? 'plugins.' : ''
html = "<div class='form-horizontal'>"
Method slug_url_field
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def slug_url_field(name, repo_slug = nil, generate_url_with_repo_slug = nil)
url = ""
html = ""
case obj['jsonmodel_type']
- 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 templates_for_js
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def templates_for_js(jsonmodel_type = nil)
@delivering_js_templates = true
result = ""
return result if @templates.blank?
- 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 jsonmodel_schema_definition
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def jsonmodel_schema_definition(property)
schema = @jsonmodel.schema
properties = Array(property).clone
if @root
- 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 label_and_readonly
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def label_and_readonly(name, default = "", opts = {})
value = obj[name]
if !(value.is_a? String)
value = value.to_s
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
Method notes_preview
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def notes_preview(notes_index = "notes", content_index = "content")
content_label = I18n.t("note._frontend.preview.content")
html = ""
if obj[notes_index] && obj[notes_index].length > 0
Consider simplifying this complex logical expression. Open
options[:checked] = "checked" if force_checked or (obj[name] === true) or (obj[name].is_a? String and obj[name].start_with?("true")) or (obj[name] === "1") or (obj[name].nil? and default)
Consider simplifying this complex logical expression. Open
options[:checked] = "checked" if force_checked or (obj[name] === true) or (obj[name].is_a? String and obj[name].start_with?("true")) or (obj[name] === "REPLACE") or (obj[name].nil? and default)
Method textfield
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def textfield(name = nil, value = nil, opts = {})
value ||= obj[name] if !name.nil?
value = value[0...-4] if value.is_a? String and value.end_with?("_REQ")
value = nil if value === "REQ"
- 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 checkboxes_for_oai_sets
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def checkboxes_for_oai_sets(set_json, value_list)
return "" if value_list == nil
# when called by #new, set_json will be nil.
if set_json
set_arry = JSON::parse(set_json)
- 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 form_context
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def form_context(name, values_from = {}, &body)
context = FormContext.new(name, values_from, self)
env = self.request.env
env['form_context_depth'] ||= 0
- 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
Avoid deeply nested control flow statements. Open
elsif schema["properties"][property]["type"] === "array"
# this view doesn't support arrays
next
elsif value.is_a? Hash
# can't display an object either
Method default_for
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def default_for(name)
if jsonmodel_schema_definition(name)
if jsonmodel_schema_definition(name).has_key?('dynamic_enum')
if jsonmodel_schema_definition(name)['default']
Rails.logger.warn("Superfluous default value at: #{@jsonmodel}.#{name} ")
- 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
Avoid deeply nested control flow statements. Open
value = value.blank? ? "" : value.to_s
Method textarea
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def textarea(name = nil, value = "", opts = {})
return "" if value.blank?
opts[:escape] = true unless opts[:escape] == false
opts[:base_url] ||= "/"
value = clean_mixed_content(value, opts[:base_url]) if opts[:clean] == 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"
Further reading
Method record_level_merge_controls
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def record_level_merge_controls(form, name = "undefined", controls = true, replace = true, append = true)
Method button_with_tooltip
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def button_with_tooltip(tooltip, content, div_classes = [], button_classes = [], use_default_btn_classes = true)
Method textarea_ro
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def textarea_ro(name = nil, value = "", opts = {})
return "" if value.blank?
opts[:escape] = true unless opts[:escape] == false
opts[:base_url] ||= "/"
value = clean_mixed_content(value, opts[:base_url]) if opts[:clean] == 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"
Further reading
Method textfield
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def textfield(name = nil, value = "", opts = {})
return "" if value.blank?
opts[:escape] = true unless opts[:escape] == false
opts[:base_url] ||= "/"
value = clean_mixed_content(value, opts[:base_url]) if opts[:clean] == 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"
Further reading
Method notes_preview
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def notes_preview(notes_index = "notes", content_index = "content")
content_label = I18n.t("note._frontend.preview.content")
html = ""
if obj[notes_index] && obj[notes_index].length > 0
- 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 select
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def select(name, options, opts = {})
if opts.has_key? :class
opts[:class] << " form-control"
else
opts[:class] = "form-control"
- 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
begin
jsonmodel_type = obj["jsonmodel_type"]
prefix = opts[:plugin] ? 'plugins.' : ''
schema = JSONModel(jsonmodel_type).schema
if (schema["properties"][name].has_key?('dynamic_enum'))
- 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 70.
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
Identical blocks of code found in 2 locations. Consider refactoring. Open
begin
jsonmodel_type = obj["jsonmodel_type"]
prefix = opts[:plugin] ? 'plugins.' : ''
schema = JSONModel(jsonmodel_type).schema
if (schema["properties"][name].has_key?('dynamic_enum'))
- 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 70.
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 textfield(name = nil, value = "", opts = {})
return "" if value.blank?
opts[:escape] = true unless opts[:escape] == false
opts[:base_url] ||= "/"
value = clean_mixed_content(value, opts[:base_url]) if opts[:clean] == 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 60.
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 textarea_ro(name = nil, value = "", opts = {})
return "" if value.blank?
opts[:escape] = true unless opts[:escape] == false
opts[:base_url] ||= "/"
value = clean_mixed_content(value, opts[:base_url]) if opts[:clean] == 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 60.
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
options[:checked] = "checked" if force_checked or (obj[name] === true) or (obj[name].is_a? String and obj[name].start_with?("true")) or (obj[name] === "REPLACE") or (obj[name].nil? and default)
@forms.tag("input", options.merge(opts), false, false)
- 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 37.
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
options[:checked] = "checked" if force_checked or (obj[name] === true) or (obj[name].is_a? String and obj[name].start_with?("true")) or (obj[name] === "1") or (obj[name].nil? and default)
@forms.tag("input", options.merge(opts), false, false)
- 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 37.
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
if replace
html << '<label class="replace-control">'
html << form.merge_checkbox('replace')
html << '<small>'
html << I18n.t("actions.merge_replace").to_s
- 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 26.
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
if append
html << '<label class="append-control">'
html << form.merge_checkbox('append')
html << '<small>'
html << I18n.t("actions.merge_add").to_s
- 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 26.
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