tansaku/LocalSupport

View on GitHub

Showing 11 of 943 total issues

Class Organisation has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

class Organisation < BaseOrganisation

  has_many :volunteer_ops
  has_many :users
  has_many :edits, class_name: 'ProposedOrganisationEdit', :dependent => :destroy
Severity: Minor
Found in app/models/organisation.rb - About 3 hrs to fix

    Class VolunteerOpsController has 22 methods (exceeds 20 allowed). Consider refactoring.
    Open

    class VolunteerOpsController < ApplicationController
      add_breadcrumb 'Volunteers', :root_url
      layout 'two_columns_with_map'
      before_action :set_organisation, only: [:new, :create]
      before_action :authorize, except: [:search, :show, :index]
    Severity: Minor
    Found in app/controllers/volunteer_ops_controller.rb - About 2 hrs to fix

      Function invite_users has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          $.fn.invite_users = function () {
              $(this).click(function () {
                  var values = {},
                      checks = $('input:checked');
                  checks.each(function () {
      Severity: Minor
      Found in app/assets/javascripts/invitations.js - About 1 hr to fix

        Function initMap has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function initMap() {
        
          map = new google.maps.Map(document.getElementById(Settings.id), {
            center: {lat: Settings.lat, lng: Settings.lng},
            zoom: Settings.zoom
        Severity: Minor
        Found in app/assets/javascripts/maps.js - About 1 hr to fix

          Method <=> has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def <=> other
                if (@sym == :what_they_do && other.sym == :how_they_help) || (@sym == :what_they_do && other.sym == :who_they_help) ||
                  (@sym == :who_they_help && other.sym == :how_they_help)
                  -1
                elsif @sym == other.sym
          Severity: Minor
          Found in app/models/category.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

          Consider simplifying this complex logical expression.
          Open

                if (@sym == :what_they_do && other.sym == :how_they_help) || (@sym == :what_they_do && other.sym == :who_they_help) ||
                  (@sym == :who_they_help && other.sym == :how_they_help)
                  -1
                elsif @sym == other.sym
                  0
          Severity: Major
          Found in app/models/category.rb - About 40 mins to fix

            Method initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              def initialize(listener, params, model_klass, user_klass, mailer_klass)
            Severity: Minor
            Found in app/services/create_proposed_organisation_edit.rb - About 35 mins to fix

              Method with has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                def self.with(listener, params, model_klass = ProposedOrganisationEdit, user_klass = User, mailer_klass = AdminMailer)
              Severity: Minor
              Found in app/services/create_proposed_organisation_edit.rb - About 35 mins to fix

                Method create_and_validate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                  def self.create_and_validate(attributes)
                    # create!(attributes.select{|k,v| !v.nil?})
                    create!(attributes.each { |k, v| attributes[k] =v.nil? ? 'No information recorded' : (v.empty? ? 'No information recorded' : v) })
                  end
                Severity: Minor
                Found in app/models/organisation.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 build_map_markers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def build_map_markers(organisations)
                    ::MapMarkerJson.build(organisations) do |org, marker|
                      marker.lat org.latitude
                      marker.lng org.longitude
                      marker.infowindow render_to_string(partial: 'organisations/popup', locals: {org: org})
                Severity: Minor
                Found in app/controllers/base_organisations_controller.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 render_error has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def render_error(status, error)
                    raise error unless Rails.env.production?
                
                    Rails.logger.error error.message
                    error.backtrace.each_with_index { |line, index| Rails.logger.error line; break if index >= 5 }
                Severity: Minor
                Found in lib/custom_errors.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