earlymarket/CoPosition

View on GitHub

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)
Severity: Minor
Found in app/models/user.rb - About 3 hrs to fix

    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
    Severity: Minor
    Found in spec/models/device_spec.rb - About 3 hrs to fix

      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
      
      
      Severity: Minor
      Found in spec/controllers/api/v1/users/checkins_controller_spec.rb - About 2 hrs to fix

        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
        Severity: Minor
        Found in app/models/device.rb - About 2 hrs to fix

          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
          
          
          Severity: Minor
          Found in spec/controllers/users/devices_controller_spec.rb - About 2 hrs to fix

            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);
            Severity: Minor
            Found in app/assets/javascripts/copo/copo.delay-slider.js - About 1 hr to fix

              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,
              Severity: Minor
              Found in app/presenters/users/devices/devices_show_presenter.rb - About 1 hr to fix

                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)
                Severity: Minor
                Found in app/controllers/api/v1/users/devices_controller.rb - About 55 mins to fix

                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
                Severity: Minor
                Found in app/models/user.rb - About 45 mins to fix

                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]
                Severity: Minor
                Found in app/controllers/api/v1/users/permissions_controller.rb - About 45 mins to fix

                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?
                Severity: Minor
                Found in app/presenters/users/devices/devices_show_presenter.rb - About 35 mins to fix

                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]
                Severity: Minor
                Found in app/models/device.rb - About 25 mins to fix

                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)
                Severity: Minor
                Found in app/presenters/users/approvals_presenter.rb - About 25 mins to fix

                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)
                Severity: Minor
                Found in app/helpers/permissions_helper.rb - About 25 mins to fix

                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
                Severity: Minor
                Found in app/presenters/activities_presenter.rb - About 25 mins to fix

                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,
                Severity: Minor
                Found in app/presenters/users/devices/devices_show_presenter.rb - About 25 mins to fix

                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|
                Severity: Minor
                Found in app/interactors/firebase/push.rb - About 25 mins to fix

                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

                Severity
                Category
                Status
                Source
                Language