Showing 259 of 471 total issues
Method initialize
has 67 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
super(user)
can :vote_in, ::Poll do |poll|
user.is_logged_in? &&
StanceModel
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export default class StanceModel extends BaseModel {
static singular = 'stance';
static plural = 'stances';
static indices = ['pollId', 'latest', 'participantId'];
static uniqueIndices = ['id'];
Function insertImage
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export function insertImage(file, view, coordinates, attachImageFile) {
const { schema } = view.state
const id = "image"+(count++)
// Replace the selection with a placeholder
- 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 64 lines of code (exceeds 25 allowed). Consider refactoring. Open
def index
if group_or_org_id.to_i == 0
rel = PgSearch.multisearch(params[:query]).where("group_id is null and discussion_id IN (:discussion_ids)", discussion_ids: current_user.guest_discussion_ids)
end
Class RecordCloner
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class RecordCloner
def initialize(recorded_at:)
@recorded_at = recorded_at
@cache = {}
end
File poll_service.js
has 269 lines of code (exceeds 250 allowed). Consider refactoring. Open
import Session from '@/shared/services/session';
import Records from '@/shared/services/records';
import Flash from '@/shared/services/flash';
import EventBus from '@/shared/services/event_bus';
import AbilityService from '@/shared/services/ability_service';
Function actions
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
actions(outcome) {
const poll = outcome.poll();
const user = Session.user();
return {
File record_cache.rb
has 268 lines of code (exceeds 250 allowed). Consider refactoring. Open
class RecordCache
attr_accessor :scope
attr_accessor :exclude_types
attr_accessor :user_ids
attr_accessor :current_user_id
Method relations
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def self.relations(model:, actor:)
rels = []
if model.is_a?(Group) and model.members.exists?(actor.id)
rels.push User.joins('LEFT OUTER JOIN memberships m ON m.user_id = users.id').
where('m.group_id IN (:group_ids) AND m.revoked_at IS NULL', {group_ids: model.group.id})
- 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
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.import(filename, group_id)
user_ids = {}
discussion_ids = {}
comment_ids = {}
Method import
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def self.import(filename, group_id)
user_ids = {}
discussion_ids = {}
comment_ids = {}
- 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 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(user)
super(user)
can [:show,
:print,
Function default
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function(callback) {
const client = new RestfulClient('boot');
client.get('site').then(function(appConfig) {
appConfig.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
forEach(appConfig, (v, k) => Vue.set(AppConfig, k, v));
Method new_clone_poll
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
def new_clone_poll(poll)
copy_fields = %w[
author_id
closing_at
closed_at
Class Base
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
class Clients::Base
attr_reader :key
def self.instance
new(
UserModel
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
export default class UserModel extends BaseModel {
static singular = 'user';
static plural = 'users';
static uniqueIndices = ['id'];
Function groupPrivacy
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
export var groupPrivacy = function(group, privacy) {
privacy = privacy || group.groupPrivacy;
if (group.isParent()) {
switch (privacy) {
- 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 create_chatbots_for_group
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_chatbots_for_group(group)
event_kinds = %w[
new_discussion
discussion_edited
poll_created
Method for_collection
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.for_collection(collection, user_id, exclude_types = [])
obj = self.new
obj.exclude_types = exclude_types
obj.current_user_id = user_id
return obj unless item = collection.to_a.first
Function actions
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
actions(attachment) {
return {
delete_attachment: {
icon: 'mdi-delete',
name: 'common.action.delete',