roqua/quby_engine

View on GitHub
lib/quby/questionnaires/deserializer.rb

Summary

Maintainability
D
2 days
Test Coverage

File deserializer.rb has 404 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Quby
  module Questionnaires
    module Deserializer
      # This symbolizes various things. Do not run on arbitrary JSON.
      def self.from_json(json)
Severity: Minor
Found in lib/quby/questionnaires/deserializer.rb - About 5 hrs to fix

    Method build_question has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.build_question(questionnaire, item_json, parent: nil, table: nil)
            key = item_json.fetch("key").to_sym
            attributes = {
              questionnaire: questionnaire,
              parent: parent,
    Severity: Major
    Found in lib/quby/questionnaires/deserializer.rb - About 3 hrs to fix

      Method from_json has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def self.from_json(json)
              # TODO: last_update
              Entities::Questionnaire.new(json.fetch("key"), json).tap do |questionnaire|
                questionnaire.title = json.fetch("title")
                questionnaire.description = json.fetch("description")
      Severity: Major
      Found in lib/quby/questionnaires/deserializer.rb - About 2 hrs to fix

        Method build_question_validation has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def self.build_question_validation(attrs)
                base_validation = {
                  type: attrs.fetch("type").to_sym,
                  explanation: attrs["explanation"] # not always specified for min/max validation
                }
        Severity: Major
        Found in lib/quby/questionnaires/deserializer.rb - About 2 hrs to fix

          Method build_chart has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def self.build_chart(questionnaire, chart_json)
                  base_args = {
                    title: chart_json.fetch("title"),
                    plottables: chart_json.fetch("plottables").map do |plottable_json|
                      Quby::Questionnaires::Entities::Charting::Plottable.new(
          Severity: Minor
          Found in lib/quby/questionnaires/deserializer.rb - About 1 hr to fix

            Method load_item has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def self.load_item(questionnaire, item_json, panel: nil)
                    case item_json.fetch("type")
                    when "text"
                      panel.items << build_text(item_json)
                    when "question"
            Severity: Minor
            Found in lib/quby/questionnaires/deserializer.rb - About 1 hr to fix

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

                      when "radio", "scale"
                        Entities::Questions::RadioQuestion.new(key, attributes).tap do |question|
                          item_json.fetch("options").each do |option_json|
                            question.options << build_option(questionnaire, question, option_json)
              Severity: Minor
              Found in lib/quby/questionnaires/deserializer.rb and 1 other location - About 15 mins to fix
              lib/quby/questionnaires/deserializer.rb on lines 203..206

              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

                      when "deprecated", "hidden"
                        Entities::Questions::DeprecatedQuestion.new(key, attributes).tap do |question|
                          item_json.fetch("options").each do |option_json|
                            question.options << build_option(questionnaire, question, option_json)
              Severity: Minor
              Found in lib/quby/questionnaires/deserializer.rb and 1 other location - About 15 mins to fix
              lib/quby/questionnaires/deserializer.rb on lines 221..224

              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

              There are no issues that match your filters.

              Category
              Status