assemblymade/coderwall

View on GitHub
app/controllers/opportunities_controller.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Class OpportunitiesController has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class OpportunitiesController < ApplicationController
  before_action :lookup_team, only: [:activate, :deactivate, :new, :create, :edit, :update, :visit]
  before_action :lookup_opportunity, only: [:edit, :update, :activate, :deactivate, :visit]
  before_action :cleanup_params_to_prevent_tagging_error
  before_action :validate_permissions, only: [:new, :edit, :create, :update, :activate, :deactivate]
Severity: Minor
Found in app/controllers/opportunities_controller.rb - About 2 hrs to fix

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

      def get_jobs_for(chosen_location, tag, page, query = nil, remote_allowed = false)
        scope = Opportunity
    
        escaped_query = query.nil? ? query : Regexp.escape(query)
    
    
    Severity: Minor
    Found in app/controllers/opportunities_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 index has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

      def index
        current_user.seen(:jobs) if signed_in?
        store_location! unless signed_in?
        chosen_location = (params[:location] || closest_to_user(current_user)).try(:titleize)
        chosen_location = nil if chosen_location == 'Worldwide'
    Severity: Minor
    Found in app/controllers/opportunities_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 get_jobs_for has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

      def get_jobs_for(chosen_location, tag, page, query = nil, remote_allowed = false)
    Severity: Minor
    Found in app/controllers/opportunities_controller.rb - About 35 mins to fix

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

        def create
          opportunity_create_params = params.require(:opportunity).permit(:name, :team_id, :opportunity_type, :description, :tag_list, :location, :link, :salary, :apply, :remote)
          @job = Opportunity.new(opportunity_create_params)
          respond_to do |format|
            if @job.save
      Severity: Minor
      Found in app/controllers/opportunities_controller.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

      There are no issues that match your filters.

      Category
      Status