earlymarket/CoPosition

View on GitHub

Showing 82 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

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

        CONSUMER_COUNT_HEADERS = %w[Month Total Growth]
      
        menu parent: "Reports"
      
        content do
      Severity: Major
      Found in app/admin/consumer_count.rb and 2 other locations - About 2 hrs to fix
      app/admin/active_user_count.rb on lines 2..34
      app/admin/checkin_count.rb on lines 2..34

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

        CHECKIN_COUNT_HEADERS = %w[Month Total Growth]
      
        menu parent: "Reports"
      
        content do
      Severity: Major
      Found in app/admin/checkin_count.rb and 2 other locations - About 2 hrs to fix
      app/admin/active_user_count.rb on lines 2..34
      app/admin/consumer_count.rb on lines 2..34

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 3 locations. Consider refactoring.
      Open

        ACTIVE_USER_HEADERS = %w[Month Total Growth]
      
        menu parent: "Reports"
      
        content do
      Severity: Major
      Found in app/admin/active_user_count.rb and 2 other locations - About 2 hrs to fix
      app/admin/checkin_count.rb on lines 2..34
      app/admin/consumer_count.rb on lines 2..34

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 98.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              describe "#can_bypass_delay?" do
                let(:permission) { double "permission", bypass_delay: bypass_delay }
                let(:permissions) { double "permissions" }
                let(:permissible) { create :user }
            
            
            Severity: Major
            Found in spec/models/device_spec.rb and 1 other location - About 2 hrs to fix
            spec/models/device_spec.rb on lines 305..334

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 84.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              describe "#can_bypass_fogging?" do
                let(:permission) { double "permission", bypass_fogging: bypass_fogging }
                let(:permissions) { double "permissions" }
                let(:permissible) { create :user }
            
            
            Severity: Major
            Found in spec/models/device_spec.rb and 1 other location - About 2 hrs to fix
            spec/models/device_spec.rb on lines 339..368

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 84.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    it "is case insensitive" do
                      approval_count = Approval.where(approvable_type: "User").count
                      post :create, params: friend_approval_create_params_upcased
                      expect(Approval.where(approvable_type: "User").count).to eq approval_count + 2
                      expect(Approval.where(user: user, approvable: friend, status: "pending")).to exist
              Severity: Major
              Found in spec/controllers/users/approvals_controller_spec.rb and 1 other location - About 1 hr to fix
              spec/controllers/users/approvals_controller_spec.rb on lines 52..57

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 52.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                    it "creates a pending approval, friend request" do
                      approval_count = Approval.where(approvable_type: "User").count
                      post :create, params: friend_approval_create_params
                      expect(Approval.where(approvable_type: "User").count).to eq approval_count + 2
                      expect(Approval.where(user: user, approvable: friend, status: "pending")).to exist
              Severity: Major
              Found in spec/controllers/users/approvals_controller_spec.rb and 1 other location - About 1 hr to fix
              spec/controllers/users/approvals_controller_spec.rb on lines 60..65

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 52.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                end
              
                page_action :active_csv, method: :get do
                  collection = active_distribution
              
              
              Severity: Major
              Found in app/admin/device_distribution.rb and 1 other location - About 1 hr to fix
              app/admin/device_distribution.rb on lines 78..92

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 51.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                end
              
                page_action :full_csv, method: :get do
                  collection = full_distribution
              
              
              Severity: Major
              Found in app/admin/device_distribution.rb and 1 other location - About 1 hr to fix
              app/admin/device_distribution.rb on lines 94..108

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 51.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def distance_stats
                    devices = copo_mobile_devices { |dev| !dev.config.custom["distanceInterval"].nil? }
                    return ["n/a"] * DISTANCE_INTERVALS.size if devices.size.zero?
              
                    DISTANCE_INTERVALS.map do |interval|
              Severity: Major
              Found in app/admin/device_settings.rb and 1 other location - About 1 hr to fix
              app/admin/device_settings.rb on lines 92..100

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  def time_stats
                    devices = copo_mobile_devices { |dev| !dev.config.custom["timeInterval"].nil? }
                    return ["n/a"] * TIME_INTERVALS.size if devices.size.zero?
              
                    TIME_INTERVALS.map do |interval|
              Severity: Major
              Found in app/admin/device_settings.rb and 1 other location - About 1 hr to fix
              app/admin/device_settings.rb on lines 105..113

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    def interval_stats
                      devices = copo_mobile_devices { |dev| !dev.config.custom["intervalType"].nil? }
                      return ["n/a"] * INTERVAL_TYPES.size if devices.size.zero?
                
                      INTERVAL_TYPES.map do |type|
                Severity: Major
                Found in app/admin/device_settings.rb and 1 other location - About 1 hr to fix
                app/admin/device_settings.rb on lines 118..126

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 48.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                    def battery_stats
                      devices = copo_mobile_devices { |dev| !dev.config.custom["batterySaving"].nil? }
                      return ["n/a"] * BATTERY_SAVING.size if devices.size.zero?
                
                      BATTERY_SAVING.map do |battery|
                Severity: Major
                Found in app/admin/device_settings.rb and 1 other location - About 1 hr to fix
                app/admin/device_settings.rb on lines 79..87

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 48.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Severity
                Category
                Status
                Source
                Language