bio-miga/miga-web

View on GitHub
app/controllers/projects_controller.rb

Summary

Maintainability
F
3 days
Test Coverage

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,
Severity: Minor
Found in app/controllers/projects_controller.rb - About 7 hrs to fix

    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,
    Severity: Minor
    Found in app/controllers/projects_controller.rb - About 4 hrs to fix

      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)
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 2 hrs 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 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)
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 2 hrs 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 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)
      Severity: Minor
      Found in app/controllers/projects_controller.rb - About 1 hr to fix

        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)
        Severity: Minor
        Found in app/controllers/projects_controller.rb - About 1 hr 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 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]
        Severity: Minor
        Found in app/controllers/projects_controller.rb - About 1 hr 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 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
        Severity: Minor
        Found in app/controllers/projects_controller.rb - About 1 hr to fix

          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)
          Severity: Minor
          Found in app/controllers/projects_controller.rb - About 1 hr to fix

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

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

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

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