bio-miga/miga-web

View on GitHub
app/controllers/query_datasets_controller.rb

Summary

Maintainability
D
2 days
Test Coverage

Method create has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

  def create
    @project = Project.find_by(id: query_dataset_params[:project_id])
    if @project.nil?
      redirect_to projects_path
    else
Severity: Minor
Found in app/controllers/query_datasets_controller.rb - About 7 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 list_query_datasets has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def list_query_datasets
    if params[:project_id]
      @project = Project.find(params[:project_id])
      qd = params[:all] ? @project.query_datasets.all :
            QueryDataset.by_user_and_project(current_user, @project)
Severity: Minor
Found in app/controllers/query_datasets_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 has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def create
    @project = Project.find_by(id: query_dataset_params[:project_id])
    if @project.nil?
      redirect_to projects_path
    else
Severity: Major
Found in app/controllers/query_datasets_controller.rb - About 2 hrs to fix

    Method result has a Cognitive Complexity of 15 (exceeds 5 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

    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 list_query_datasets has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def list_query_datasets
        if params[:project_id]
          @project = Project.find(params[:project_id])
          qd = params[:all] ? @project.query_datasets.all :
                QueryDataset.by_user_and_project(current_user, @project)
    Severity: Minor
    Found in app/controllers/query_datasets_controller.rb - About 1 hr to fix

      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

        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

          There are no issues that match your filters.

          Category
          Status