Showing 86 of 92 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
toggle({ params }) {
const { toggleTarget, toggleTargets } = params
if (toggleTarget) {
this.toggleAvoTarget(toggleTarget)
- 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 82.
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
Function tagifyOptions
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
get tagifyOptions() {
let options = {
whitelist: this.whitelistItemsValue,
blacklist: this.disallowedItemsValue,
enforceWhitelist: this.enforceSuggestionsValue,
Method index
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
@page_title = @resource.plural_name.humanize
if @reflection.present? && !turbo_frame_request?
add_breadcrumb @record.class.to_s.pluralize, resources_path(resource: @parent_resource)
Method names_mapping
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def names_mapping
{
id: {
field: "id"
},
Method initialize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def initialize(**args)
# Extend the class with custom modules if required.
if args[:include].present?
args[:include].each do |mod|
self.class.send(:include, mod)
- 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 generated_fields_template
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def generated_fields_template
return if fields.blank?
fields_string = ""
- 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
Function uploadFile
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
uploadFile(file, progressCallback, successCallback) {
const formData = this.createFormData(file)
const xhr = new XMLHttpRequest()
xhr.open('POST', this.uploadUrl, true)
Method create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
# This means that the record has been created through another parent record and we need to attach it somehow.
if params[:via_record_id].present? && params[:via_belongs_to_resource_class].nil?
@reflection = @record.class.reflect_on_association(params[:via_relation])
# Figure out what kind of association does the record have with the parent record
Function connect
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
connect() {
if (this.attachmentsDisabledValue) {
// Remove the attachments button
this.controllerTarget.querySelector('.trix-button-group--file-tools').remove()
}
Method avo_metadata
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def avo_metadata
resources = Avo.resource_manager.all
dashboards = Avo::Current.app.dashboard_manager.all
field_definitions = resources.map(&:get_field_definitions)
fields_count = field_definitions.map(&:count).sum
Method only_fields
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def only_fields(only_root: false)
fields = []
items.each do |item|
next if item.nil?
Method eject_field_components
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def eject_field_components
# Check if the field exists
field_path = "lib/avo/fields/#{options["field-components"]}_field.rb"
return say("Failed to find the `#{options["field-components"]}` field.", :yellow) if !path_exists?(field_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
markExpanded(animate = false) {
this.svgTarget.classList.remove('rotate-90')
if (animate) {
enter(this.itemsTarget)
} else {
- 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
markCollapsed(animate = false) {
this.svgTarget.classList.add('rotate-90')
if (animate) {
leave(this.itemsTarget)
} else {
- 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 initialize
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def initialize(id, **args, &block)
args[:name] ||= "Avatar"
super(id, **args, &block)
- 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 button_classes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def button_classes(extra_classes = nil, color: nil, variant: nil, size: :md, active: false)
classes = "inline-flex flex-grow-0 items-center text-sm font-semibold leading-6 fill-current whitespace-nowrap transition duration-100 rounded transform transition duration-100 active:translate-x-px active:translate-y-px cursor-pointer disabled:cursor-not-allowed #{extra_classes}"
if color.present?
if variant.present? && (variant.to_sym == :outlined)
- 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 respond
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def respond
# Flash the messages collected from the action
flash_messages
respond_to do |format|
- 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 initialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def initialize(id, **args, &block)
super(id, **args, &block)
@link_to_record = args[:link_to_record].present? ? args[:link_to_record] : false
- 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 render_action
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def render_action(action)
return if !can_see_the_actions_button?
return if !action.action.visible_in_view(parent_resource: @parent_resource)
a_link action.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 computed_cache_store
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def computed_cache_store
-> {
if Rails.env.production?
if Rails.cache.class.to_s.in?(production_rejected_cache_stores)
ActiveSupport::Cache.lookup_store(:file_store, Rails.root.join("tmp", "cache"))
- 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"