Showing 17 of 82 total issues
Class User
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
class User < ApplicationRecord
extend FriendlyId
include ApprovalMethods, SlackNotifiable, RemoveId
PUBLIC_ATTRIBUTES = %i(id username slug email)
File device_spec.rb
has 317 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "rails_helper"
RSpec.describe Device, type: :model do
let(:developer) { create :developer }
let(:device) do
File checkins_controller_spec.rb
has 272 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rails_helper'
RSpec.describe Api::V1::CheckinsController, type: :controller do
include ControllerMacros, CityMacros
Class Device
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class Device < ApplicationRecord
include SlackNotifiable, RemoveId, PublicActivity::Common
belongs_to :user
has_one :config, dependent: :destroy
File devices_controller_spec.rb
has 270 lines of code (exceeds 250 allowed). Consider refactoring. Open
require "rails_helper"
RSpec.describe Users::DevicesController, type: :controller do
include ControllerMacros
Function initSliders
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
initSliders: function(devices){
$('.delay-slider').each(function(){
if(!this.noUiSlider){
var delaySlider = this;
var device_id = parseInt(delaySlider.dataset.device, 10);
Method form_range_filter
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def form_range_filter(text, from)
if device_page?
link_to text,
user_device_path(
user.url_id,
Method show
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def show
device = @user.devices.where(id: params[:id]).first
unless req_from_coposition_app?
return unless device_exists?(device) && !device.cloaked?
device = device.public_info unless @dev.configures_device?(device)
- 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 approve_devices
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def approve_devices(permissible)
devices.includes(:developers, :permitted_users).each do |device|
if permissible.class.to_s == "Developer"
device.developers << permissible unless device.developers.include? permissible
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 require_ownership
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def require_ownership
if params[:id]
render status: 403, json: { error: 'You do not control that permission' } unless user_owns_permission?
else
params[:id] = params[:device_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 initialize
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def initialize(user, params)
@user = user
@params = params
@owner = device_page? ? Device.find(params[:id]) : user
@device = Device.find(params[:id]) if device_page?
- 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 sanitize_checkins
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sanitize_checkins(sanitized, args)
if args[:type] == "address"
sanitized.map(&:reverse_geocode!) unless args[:action] == "index" && args[:multiple_devices]
end
return sanitized if args[:copo_app]
- 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 add_color_info
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_color_info(list)
return unless list
list.each_with_index do |item, index|
next unless item.respond_to?(:pin_color)
- 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 permissions_permissible_title
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def permissions_permissible_title(user, permissible)
title = '<div class="valign-wrapper permission-title">'
title += avatar_for(permissible)
title += '<div><div><span class="permissible-name">'
title += approvals_approvable_name(permissible)
- 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 activities
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def activities
activities = if @params[:search]
filter_trackable_types.present? ? load_activities.where(trackable_type: filter_trackable_types) : load_activities
else
filter_params || PublicActivity::Activity.all
- 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 form_range_filter
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def form_range_filter(text, from)
if device_page?
link_to text,
user_device_path(
user.url_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 info_hash
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def info_hash
{
to: "/topics/#{env_topic}",
priority: "high"
}.tap do |h|
- 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"