app/controllers/jobs_controller.rb

Summary

Maintainability
A
25 mins
Test Coverage

User controlled method execution
Open

    @result, @datas, @sum_report, @errors = @job.send("#{@default_view}_views", (@transport_datas_selected != 'all' ? @transport_datas_selected : nil ))
Severity: Critical
Found in app/controllers/jobs_controller.rb by brakeman

Using unfiltered user data to select a Class or Method to be dynamically sent is dangerous.

It is much safer to whitelist the desired target or method.

Unsafe use of method:

method = params[:method]
@result = User.send(method.to_sym)

Safe:

method = params[:method] == 1 ? :method_a : :method_b
@result = User.send(method, *args)

Unsafe use of target:

table = params[:table]
model = table.classify.constantize
@result = model.send(:method)

Safe:

target = params[:target] == 1 ? Account : User
@result = target.send(:method, *args)

Including user data in the arguments passed to an Object#send is safe, as long as the method can properly handle potentially bad data.

Safe:

args = params["args"] || []
@result = User.send(:method, *args)

Method job has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def job
    @job = Job.find(params[:id])
    @job.search = params[:q][:search] if params[:q]
    @current_menu = @job.convert_job? ? :convert : :validate
  rescue => _e
Severity: Minor
Found in app/controllers/jobs_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

TODO found
Open

    # TODO - Faire une classe services pour toutes les vars
Severity: Minor
Found in app/controllers/jobs_controller.rb by fixme

There are no issues that match your filters.

Category
Status