mluukkai/labtool

View on GitHub
app/controllers/checklists_controller.rb

Summary

Maintainability
F
3 days
Test Coverage

Method update_values has a Cognitive Complexity of 48 (exceeds 5 allowed). Consider refactoring.
Open

  def update_values
    @checklist = Checklist.find params[:id]
    @checklist.grade_callback = params[:checklist][:grade_callback]
    @checklist.title = params[:checklist][:title]
    @checklist.save
Severity: Minor
Found in app/controllers/checklists_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 yaml_to_topics has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

  def yaml_to_topics(yaml)
    ordering = 1
    topics = YAML.load(yaml).map do |thash|
      thash = parse_ids_from :topic, thash
      if thash.has_key? "id"
Severity: Minor
Found in app/controllers/checklists_controller.rb - About 5 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 update_values has 98 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def update_values
    @checklist = Checklist.find params[:id]
    @checklist.grade_callback = params[:checklist][:grade_callback]
    @checklist.title = params[:checklist][:title]
    @checklist.save
Severity: Major
Found in app/controllers/checklists_controller.rb - About 3 hrs to fix

    File checklists_controller.rb has 309 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class ChecklistsController < ApplicationController
    
      def index
        @checklists = Checklist.order :title
      end
    Severity: Minor
    Found in app/controllers/checklists_controller.rb - About 3 hrs to fix

      Method topics_to_yaml has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

        def topics_to_yaml (topics)
          StyledYAML.dump format_nice(topics.map{ |topic|
            ret = topic.attributes.reject {|key,value|
              %w(ordering checklist_id scoretype_id).include? key or value.nil? 
            }
      Severity: Minor
      Found in app/controllers/checklists_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 yaml_to_topics has 58 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def yaml_to_topics(yaml)
          ordering = 1
          topics = YAML.load(yaml).map do |thash|
            thash = parse_ids_from :topic, thash
            if thash.has_key? "id"
      Severity: Major
      Found in app/controllers/checklists_controller.rb - About 2 hrs to fix

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

          def format_nice (coll)
            if coll.is_a? Hash
              coll.each do |key, value|
                coll[key] = format_nice(value)
              end
        Severity: Minor
        Found in app/controllers/checklists_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