tansaku/LocalSupport

View on GitHub
app/controllers/volunteer_ops_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Class has too many lines. [107/100]
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]

This cop checks if the length a class exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

    Method has too many lines. [7/5] (https://github.com/bbatsov/ruby-style-guide#short-methods)
    Open

      def show
        render template: 'pages/404', status: 404 and return if @volunteer_op.nil?
        @organisation = Organisation.friendly.find(@volunteer_op.organisation_id)
        organisations = Organisation.where(id: @organisation.id)
        @editable = current_user.can_edit?(@organisation) if current_user

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Assignment Branch Condition size for show is too high. [17.72/15] (http://c2.com/cgi/wiki?AbcMetric)
    Open

      def show
        render template: 'pages/404', status: 404 and return if @volunteer_op.nil?
        @organisation = Organisation.friendly.find(@volunteer_op.organisation_id)
        organisations = Organisation.where(id: @organisation.id)
        @editable = current_user.can_edit?(@organisation) if current_user

    This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

    Method has too many lines. [7/5] (https://github.com/bbatsov/ruby-style-guide#short-methods)
    Open

      def restrict_by_feature_scope
        if Feature.active?(:doit_volunteer_opportunities) &&
           Feature.active?(:reachskills_volunteer_opportunities)
          return :all
        end

    This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

    Use && instead of and. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
    Open

        redirect_to '/' and return

    This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

    Example: EnforcedStyle: always (default)

    # bad
    foo.save and return
    
    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    if foo && bar
    end

    Example: EnforcedStyle: conditionals

    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    foo.save and return
    
    # good
    if foo && bar
    end

    Use && instead of and. (https://github.com/bbatsov/ruby-style-guide#no-and-or-or)
    Open

        render template: 'pages/404', status: 404 and return if @volunteer_op.nil?

    This cop checks for uses of and and or, and suggests using && and || instead. It can be configured to check only in conditions, or in all contexts.

    Example: EnforcedStyle: always (default)

    # bad
    foo.save and return
    
    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    if foo && bar
    end

    Example: EnforcedStyle: conditionals

    # bad
    if foo and bar
    end
    
    # good
    foo.save && return
    
    # good
    foo.save and return
    
    # good
    if foo && bar
    end

    There are no issues that match your filters.

    Category
    Status