Showing 78 of 97 total issues
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 search_resources
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def search_resources(resources)
resources
.map do |resource|
# Apply authorization
next unless @authorization.set_record(resource.model_class).authorize_action(:search, raise_exception: 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
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._reflections[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 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 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 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
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 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 perform_action_and_record_errors
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def perform_action_and_record_errors(&block)
begin
succeeded = block.call
rescue => exception
# In case there's an error somewhere else than the record
- 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"
Further reading
Method default_strategy
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def default_strategy
# If the app uses Propshaft, grab it from there
if defined?(Propshaft)
asset_path = ::Rails.application.assets.load_path.find(@filename)
asset_path&.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 classes
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def classes(extra_classes = "")
"field-wrapper relative flex flex-col grow pb-2 md:pb-0 leading-tight min-h-14 h-full #{stacked? ? "field-wrapper-layout-stacked" : "field-wrapper-layout-inline md:flex-row md:items-center"} #{compact? ? "field-wrapper-size-compact" : "field-wrapper-size-regular"} #{full_width? ? "field-width-full" : "field-width-regular"} #{@classes || ""} #{extra_classes || ""} #{@field.get_html(:classes, view: view, element: :wrapper)}"
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 generated_fields_template
has a Cognitive Complexity of 8 (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
Method initialize
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def initialize(id, **args, &block)
super(id, **args, &block)
@loading_when = args[:loading_when].present? ? [args[:loading_when]].flatten.map(&:to_sym) : []
@failed_when = args[:failed_when].present? ? [args[:failed_when]].flatten.map(&:to_sym) : []
- 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 apply_sorting
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def apply_sorting
return if @index_params[:sort_by].nil?
sort_by = @index_params[:sort_by].to_sym
if sort_by != :created_at
- 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 component_for_view
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def component_for_view(view = :index)
# Use the edit variant for all "update" views
view = :edit if view.in? [:new, :create, :update]
custom_components = Avo::ExecutionContext.new(
- 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 can_attach?
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def can_attach?
policy_result = true
if @field.present?
reflection_resource = @field.target_resource
- 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"