File projects_controller.rb
has 468 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'miga'
require 'miga/daemon'
class ProjectsController < ApplicationController
before_action :set_project,
Class ProjectsController
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
class ProjectsController < ApplicationController
before_action :set_project,
only: [:destroy, :show, :search, :reference_datasets,
:medoid_clade, :medoid_clade_as,
:rdp_classify, :rdp_classify_as, :new_ncbi_download,
Method create
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def create
@user = User.find_by(id: params[:user_id])
par = project_params
par[:official] = false unless @user.admin?
@project = @user.projects.create(par)
- 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
Method create_reference
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def create_reference
cmd = params.require(:query_dataset).permit(
:name, :input_type, :input_file, :input_file_2
)
cmd.merge! params.permit(:type, :comments, :description)
- 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
Method create_reference
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_reference
cmd = params.require(:query_dataset).permit(
:name, :input_type, :input_file, :input_file_2
)
cmd.merge! params.permit(:type, :comments, :description)
Method discovery
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def discovery
require 'miga/lair'
require 'pathname'
lair = MiGA::Lair.new(Settings.miga_projects)
- 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
Method search
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def search
# Query
@q = params[:q]
@query = @q.split(/\s(?=(?:[^"]|"[^"]*")*$)/).map do |i|
(i =~ /^(?:([A-Za-z_]+):)?"?(.*?)"?$/) ? [$2, $1] : [i, nil]
- 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
Method progress
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def progress
ref_ds = @project.miga.dataset_names.select { |i| i !~ /^qG_/ }
status = ref_ds.sample(100).map do |i|
@project.miga.dataset(i).status
end
Method create
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create
@user = User.find_by(id: params[:user_id])
par = project_params
par[:official] = false unless @user.admin?
@project = @user.projects.create(par)
Method launch_get_db
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def launch_get_db
name = params[:name]
version = params[:version]
Thread.new do
require 'miga/cli'
- 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
Method reference_dataset_result
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def reference_dataset_result
if p = @project and m = p.miga
if ds = m.dataset(params[:dataset]) and res = ds.result(params[:result])
if file = res.data[:files][params[:file].to_sym]
send_result(file, res)
- 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
Method result_partial
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def result_partial
if params[:q_ds].nil?
obj = @project
proj = obj
unless params[:r_ds].nil?
- 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
Method get_db
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def get_db
manif = Project.miga_online_manif
@downloadable = manif[:databases].map do |name, i|
local = Project.find_by(path: name)
local_v = (local.miga.metadata[:release] || 'unknown') if local && local.miga
- 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
Method send_result
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def send_result(file, res)
f = File.expand_path(file, res.dir)
if Dir.exist? f and params[:f] and not params[:f]=~/\//
f = File.expand_path(params[:f], f)
file = params[:f]
- 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"