CLOSER-Cohorts/archivist

View on GitHub
app/controllers/variables_controller.rb

Summary

Maintainability
A
25 mins
Test Coverage

Unsafe reflection method constantize called with parameter value
Open

    @source ||= params[:other][:class].constantize.send(:find, params[:other][:id]) rescue nil

Brakeman reports on several cases of remote code execution, in which a user is able to control and execute code in ways unintended by application authors.

The obvious form of this is the use of eval with user input.

However, Brakeman also reports on dangerous uses of send, constantize, and other methods which allow creation of arbitrary objects or calling of arbitrary methods.

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

  def add_sources
    head :bad_request if params[:sources].nil?

    params[:sources] = JSON.parse(params[:sources]) if params[:sources].is_a?(String)

Severity: Minor
Found in app/controllers/variables_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

There are no issues that match your filters.

Category
Status