Showing 48 of 56 total issues
Class User
has 39 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationRecord
extend Memoist
extend Tokenize
extend RailsAdminStatistics
Class Statistic
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
class Statistic
def statistics_category_articles c
a = Article.new(categories: [c])
articles = a.find_like_this(1)
articles.total
Class ArticlesController
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
class ArticlesController < ApplicationController
include ArticleControllerFilters
include ArticleParams
respond_to :html
Class MassUploadArticle
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class MassUploadArticle < ApplicationRecord
belongs_to :article
belongs_to :mass_upload
has_one :user, through: :mass_upload
default_scope { order('row_index ASC') }
Function generateTOC
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateTOC() {
if ($('#filecontents').length === 0) return;
var _toc = $('<ol class="top"></ol>');
var show = false;
var toc = _toc;
Function searchItem
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
function searchItem() {
for (var i = 0; i < searchCache.length / 50; i++) {
var item = searchCache[searchIndex];
var searchName = (searchString.indexOf('::') != -1 ? item.fullName : item.name);
var matchString = regexSearchString;
- 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 fullListSearch
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
function fullListSearch() {
// generate cache
searchCache = [];
$('#full_list li').each(function() {
var link = $(this).find('.object_link a');
Method attributes_for
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def attributes_for(user)
attributes = {
customer_type: user.is_a?(LegalEntity) ? 'business' : 'consumer',
organization: (user.is_a?(LegalEntity) &&
user.standard_address_company_name.present?) ?
Method article_attributes
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.article_attributes
%w(
€ id title categories condition condition_extra
content quantity price_cents basic_price_cents
basic_price_amount vat external_title_image_url image_2_url
Method validate_each
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, value)
range = options[:in]
value ||= []
value = [value] unless value.respond_to?(:size) # fix for existing entries
unless options[:allow_blank_entries]
- 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 update
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def update
super
if current_user.present?
# TODO: Remove duplicate code in passwords and sessions controllers
- 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 summaryToggle
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function summaryToggle() {
$('.summary_toggle').click(function() {
if (localStorage) {
localStorage.summaryCollapsed = $(this).text();
}
Method heart_button
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def heart_button(heartable_resource)
if user_signed_in?
heart = Heart.where(heartable: heartable_resource, user: current_user).limit 1
else
heart = Heart.where(heartable: heartable_resource, user_token: generate_user_token).limit 1
Method revenue_last_month
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def revenue_last_month
revenue = 0
fair = 0
fee = 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 validate_each
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate_each(record, attribute, selected_payment)
if record.is_a? BusinessTransaction
common_sense_error = common_sense_check selected_payment, record.selected_transport
record.errors[attribute] << common_sense_error if common_sense_error
- 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
Consider simplifying this complex logical expression. Open
unless self.payment_bank_transfer || self.payment_paypal ||
self.payment_cash || self.payment_cash_on_delivery ||
self.payment_invoice || self.payment_voucher || self.payment_debit
errors.add(:payment_details, I18n.t('article.form.errors.invalid_payment_option'))
end
Method fastbill_chain
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def fastbill_chain
@seller.with_lock do
if @seller.needs_to_be_billed?
unless @seller.has_fastbill_profile?
fastbill_create_customer
- 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 visual_checkout_step
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def visual_checkout_step step, active, checked, link = nil
step_title = I18n.t("cart.steps.#{step}")
content_tag :span, class: "visual_checkout_step #{active ? 'active' : ''}" do
concat(content_tag(:i, '', class: (checked ? 'fa fa-check-square-o' : 'fa fa-square-o')))
concat(' ')
- 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 find_by_id_or_custom_seller_identifier
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def find_by_id_or_custom_seller_identifier
if IDENTIFIERS.select { |v| @article_attributes.include?(v) && @article_attributes[v].present? }.empty?
put_error I18n.t('mass_uploads.errors.no_identifier')
nil
else
- 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 show
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def show(range)
files_found = 0
File.open('image_cleaner.txt', 'w') do |file|
for id in range
- 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"