bio-miga/miga-web

View on GitHub

Showing 40 of 40 total issues

Method estimated_wait_time has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def estimated_wait_time(project_id)
    @estimated_wait_time_last_check ||= []
    @estimated_wait_time ||= []
    if @estimated_wait_time_last_check[project_id].nil? or
          @estimated_wait_time_last_check[project_id] < 48.hours.ago
Severity: Minor
Found in app/helpers/projects_helper.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 create has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def create
     user = User.find_by(email: params[:session][:email].downcase)
     if user && user.authenticate(params[:session][:password])
    if user.activated?
       # Log the user in and redirect to the user's show page.
Severity: Minor
Found in app/controllers/sessions_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 link_to_reference_dataset has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def link_to_reference_dataset(project, dataset_name)
    pm = project.miga if project
    ds_miga = pm.dataset(dataset_name) if pm
    if ds_miga.nil?
      content_tag(:del, dataset_name, title: 'Reference dataset removed')
Severity: Minor
Found in app/helpers/projects_helper.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 result has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def result
    qd  = @query_dataset
    m   = qd.miga
    res = m.result(params[:result])
    if res.nil?
Severity: Minor
Found in app/controllers/query_datasets_controller.rb - About 1 hr to fix

    Method aai_novel has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def aai_novel(aai, project)
        opts = {}
        if project.miga && project.miga.metadata[:aai_p]
          opts[:engine] = project.miga.metadata[:aai_p]
        end
    Severity: Minor
    Found in app/helpers/query_datasets_helper.rb - About 1 hr to fix

      Method plot_assembly has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def plot_assembly(n50, len)
          # Trace1: RefSeq genomes
          trace1 = {
            x: [298471,2240716,3402093,4653910,13033779],
            type: "box",
      Severity: Minor
      Found in app/helpers/application_helper.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 display_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def display_data(obj, html_safe = false)
              case obj
              when Float
                obj.round(2).to_s
              when Array
          Severity: Minor
          Found in app/helpers/application_helper.rb - About 55 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

          Avoid deeply nested control flow statements.
          Open

                      if saved_cnt == 1
                        redirect_to @query_dataset
                      else
                        redirect_to project_query_datasets_url(@project)
                      end
          Severity: Major
          Found in app/controllers/query_datasets_controller.rb - About 45 mins to fix

            Method create_miga_dataset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def create_miga_dataset
                # Don't do anything if it already exists
                return true if project.miga.dataset(miga_name)
            
                err = project.create_miga_dataset(
            Severity: Minor
            Found in app/models/query_dataset.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 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 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

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

               def current_user
                  if (user_id = session[:user_id])
                 @current_user ||= User.find_by(id: user_id)
                  elsif (user_id = cookies.signed[:user_id])
                 user = User.find_by(id: user_id)
            Severity: Minor
            Found in app/helpers/sessions_helper.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def create
                par = user_params
                if User.all.empty?
                  par[:activated] = true
                  par[:activated_at] = Time.zone.now
            Severity: Minor
            Found in app/controllers/users_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 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 rdp_classify has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def rdp_classify(ds_name)
                ds_miga = miga.dataset(ds_name)
                return if ds_miga.nil?
                res = ds_miga.result(:ssu)
                return if res.nil?
            Severity: Minor
            Found in app/models/project.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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              def code_color
                c = Color::RGB.by_hex(code_base_color).to_hsl
                c.luminosity = 40 + c.luminosity/4
                c.saturation = 40 + c.saturation/4
                c.css_hsl
            Severity: Minor
            Found in app/models/project.rb and 1 other location - About 15 mins to fix
            app/models/project.rb on lines 70..74

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 26.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

              def code_light_color
                c = Color::RGB.by_hex(code_base_color).to_hsl
                c.luminosity = 90 + c.luminosity/10
                c.saturation = 40 + c.saturation/4
                c.css_hsl
            Severity: Minor
            Found in app/models/project.rb and 1 other location - About 15 mins to fix
            app/models/project.rb on lines 63..67

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 26.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language