Showing 1,692 of 2,021 total issues
Class User
has 168 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
include Searchable
include Roleable
include HasCustomFields
include SecondFactorManager
File users_controller.rb
has 1224 lines of code (exceeds 250 allowed). Consider refactoring. Open
class UsersController < ApplicationController
skip_before_action :authorize_mini_profiler, only: [:avatar]
requires_login only: [
File user.rb
has 1200 lines of code (exceeds 250 allowed). Consider refactoring. Open
class User < ActiveRecord::Base
include Searchable
include Roleable
include HasCustomFields
include SecondFactorManager
File topic.rb
has 1180 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Topic < ActiveRecord::Base
class UserExists < StandardError; end
include ActionView::Helpers::SanitizeHelper
include RateLimiter::OnCreateRecord
include HasCustomFields
File receiver.rb
has 990 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "digest"
module Email
class Receiver
File search.rb
has 866 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Search
DIACRITICS ||= /([\u0300-\u036f]|[\u1AB0-\u1AFF]|[\u1DC0-\u1DFF]|[\u20D0-\u20FF])/
cattr_accessor :preloaded_topic_custom_fields
self.preloaded_topic_custom_fields = Set.new
File topic_query.rb
has 856 lines of code (exceeds 250 allowed). Consider refactoring. Open
class TopicQuery
PG_MAX_INT ||= 2147483647
def self.validators
@validators ||= begin
File topics_controller.rb
has 839 lines of code (exceeds 250 allowed). Consider refactoring. Open
class TopicsController < ApplicationController
requires_login only: [
:timings,
:destroy_timings,
:update,
Class Topic
has 104 methods (exceeds 20 allowed). Consider refactoring. Open
class Topic < ActiveRecord::Base
class UserExists < StandardError; end
include ActionView::Helpers::SanitizeHelper
include RateLimiter::OnCreateRecord
include HasCustomFields
File post.rb
has 832 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'archetype'
require 'digest/sha1'
class Post < ActiveRecord::Base
include RateLimiter::OnCreateRecord
Method create_for
has a Cognitive Complexity of 91 (exceeds 5 allowed). Consider refactoring. Open
def create_for(user_id)
if filesize <= 0
@upload.errors.add(:base, I18n.t("upload.empty"))
return @upload
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
File routes.rb
has 755 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "sidekiq/web"
require "mini_scheduler/web"
# The following constants have been replaced with `RouteFormat` and are deprecated.
USERNAME_ROUTE_FORMAT = /[%\w.\-]+?/ unless defined? USERNAME_ROUTE_FORMAT
Method build
has a Cognitive Complexity of 87 (exceeds 5 allowed). Consider refactoring. Open
def build
return @wizard unless SiteSetting.wizard_enabled? && @wizard.user.try(:staff?)
@wizard.append_step('locale') do |step|
step.banner = "welcome.png"
- 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 new_user_narrative_spec.rb
has 737 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rails_helper'
describe DiscourseNarrativeBot::NewUserNarrative do
let!(:welcome_topic) { Fabricate(:topic, title: 'Welcome to Discourse') }
let(:discobot_user) { ::DiscourseNarrativeBot::Base.new.discobot_user }
Method to_html
has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring. Open
def to_html
do_quotes = do_backticks = do_dashes = do_ellipses = nil
if @options.include?(0)
# Do nothing.
- 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 posts_query
has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring. Open
def posts_query(limit, opts = nil)
opts ||= {}
posts = Post.where(post_type: Topic.visible_post_types(@guardian.user))
.joins(:post_search_data, :topic)
- 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_results
has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring. Open
def default_results(options = {})
options.reverse_merge!(@options)
options.reverse_merge!(per_page: per_page_setting)
# Whether to return visible topics
- 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 group.rb
has 692 lines of code (exceeds 250 allowed). Consider refactoring. Open
class Group < ActiveRecord::Base
include HasCustomFields
include AnonCacheInvalidator
include HasDestroyedWebHook
Class Receiver
has 82 methods (exceeds 20 allowed). Consider refactoring. Open
class Receiver
# If you add a new error, you need to
# * add it to Email::Processor#handle_failure()
# * add text to server.en.yml (parent key: "emails.incoming.errors")
class ProcessingError < StandardError; end
Class Post
has 81 methods (exceeds 20 allowed). Consider refactoring. Open
class Post < ActiveRecord::Base
include RateLimiter::OnCreateRecord
include Trashable
include Searchable
include HasCustomFields