Showing 576 of 597 total issues
File facetable.rb
has 493 lines of code (exceeds 250 allowed). Consider refactoring. Open
module Facetable
extend ActiveSupport::Concern
SOURCES = {
"datacite-usage" => "DataCite Usage Stats",
Method convert_affiliation_by_id
has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring. Open
def self.convert_affiliation_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
count = 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 index
has 184 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_score" => { order: "desc" } }
Method index
has 183 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_score" => { order: "desc" } }
Method index
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_score" => { order: "desc" } }
- 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 index
has 179 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_score" => { order: "desc" } }
File contact.rb
has 456 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Contact < ApplicationRecord
strip_attributes
# include helper module for Elasticsearch
include Indexable
Method initialize
has 169 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
alias_action :create, :read, :update, :destroy, to: :crud
user ||= User.new(nil) # Guest user
# @user = user
File providers_controller.rb
has 445 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ProvidersController < ApplicationController
include ActionController::MimeResponds
include Countable
prepend_before_action :authenticate_user!
Class Event
has 48 methods (exceeds 20 allowed). Consider refactoring. Open
class Event < ApplicationRecord
# include helper module for query caching
include Cacheable
# include event processing
Method repositories
has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring. Open
def repositories
# authorize! :export, :repositories
# Loop through all clients
page = { size: 1_000, number: 1 }
- 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 filters
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def filters
options = @options
# turn ids into an array if provided as comma-separated string
options[:ids] = options[:ids].split(",") if options[:ids].is_a?(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 import_from_providers
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def self.import_from_providers
Provider.all.find_each do |provider|
if provider.voting_contact_email
contact = Contact.where(email: provider.voting_contact_email).first_or_create
if contact.update(
- 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
File params_sanitizer.rb
has 432 lines of code (exceeds 250 allowed). Consider refactoring. Open
class ParamsSanitizer
include Crosscitable
include Helpable
DEFAULTS_MAP =
Class Client
has 46 methods (exceeds 20 allowed). Consider refactoring. Open
class Client < ApplicationRecord
SUBJECTS_JSON_SCHEMA = Rails.root.join("app", "models", "schemas", "client", "subjects.json")
audited except: %i[
system_email
service_contact
Method initialize
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user)
alias_action :create, :read, :update, :destroy, to: :crud
user ||= User.new(nil) # Guest user
# @user = user
- 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 index
has 150 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
sort =
case params[:sort]
when "relevance"
{ "_score" => { order: "desc" } }
Method aggregations
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
def aggregations
facet_count = (@options[:facet_count] || DEFAULT_FACET_COUNT).to_i
if facet_count.positive?
{
resource_types: { terms: { field: "resource_type_id_and_name", size: facet_count, min_doc_count: 1, missing: "__missing__" } },
Method repositories
has 143 lines of code (exceeds 25 allowed). Consider refactoring. Open
def repositories
# authorize! :export, :repositories
# Loop through all clients
page = { size: 1_000, number: 1 }
Method convert_affiliation_by_id
has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring. Open
def self.convert_affiliation_by_id(options = {})
return nil if options[:id].blank?
id = options[:id].to_i
count = 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"