Class ProjectsController
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
class ProjectsController < ApplicationController
before_action :set_project, only: %i[show edit update destroy import import_upload
reports ownership archive unarchive
change_archived projects_unjoined]
before_action :prepare_session, only: %i[import import_upload]
Method change_archived
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def change_archived(archive = true)
@project = policy_scope(Project).archived.friendly.find(params[:id]) unless @project
authorize @project
result = ProjectOperations::Update.call(
- Read upRead up
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
Complex method ProjectsController#change_archived (41.0) Open
def change_archived(archive = true)
@project = policy_scope(Project).archived.friendly.find(params[:id]) unless @project
authorize @project
result = ProjectOperations::Update.call(
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ProjectsController#import (39.7) Open
def import
@import_job = session[:import_job]
return if @import_job.blank?
job_result = Rails.cache.read(@import_job[:id])
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ProjectsController#create (33.7) Open
def create
@project = policy_scope(Project).new(allowed_params)
authorize @project
@project.users << current_user
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Method import
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def import
@import_job = session[:import_job]
return if @import_job.blank?
job_result = Rails.cache.read(@import_job[:id])
- Read upRead up
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
Complex method ProjectsController#update (26.4) Open
def update
result = ProjectOperations::Update.call(
project: @project,
project_attrs: allowed_params,
current_user: current_user
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ProjectsController#import_upload (24.7) Open
def import_upload
if params[:project].blank?
flash[:alert] = I18n.t('projects.uploads.select_file')
else
session[:import_job] = { id: ImportWorker.new_job_id, created_at: Time.current }
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ProjectsController#ownership (24.1) Open
def ownership
team = Team.not_archived.friendly.find(params.dig(:project, :slug))
manager = ProjectOwnership.new(@project, team, current_team, params.dig(:ownership_action))
if manager.perform
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool
Complex method ProjectsController#join (20.6) Open
def join
project = projects_unjoined.find_by!(slug: params[:id])
authorize project
project.users << current_user
- Read upRead up
- Exclude checks
Flog calculates the ABC score for methods. The ABC score is based on assignments, branches (method calls), and conditions.
You can read more about ABC metrics or the flog tool