DevelopingCoder/cs61a_hintr

View on GitHub

Showing 21 of 456 total issues

Method diff_db has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    def diff_db(qset_json)
        diffs = []
        qset_json.each do |qset_name, question_json|
            question_set = QuestionSet.find_by_name(qset_name)
            if not question_set
Severity: Minor
Found in features/support/seed_helper.rb - About 3 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 check_tags_exist has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def self.check_tags_exist(file_qsets)
        non_exist_tags = []
        file_qsets.keys.each do |qset_name|
            question_hash = file_qsets[qset_name]
            question_hash.each do |question_text, wrong_answer_list|
Severity: Minor
Found in app/models/question_set.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 find_edits has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def find_edits(wrong_answer_list)
        db_display_list = {} # wrong answers shown (edited or deleted)
        upload_display_list = {} #wrong answers shown (edited or added)
        
        db_wrong_answer_list = self.wrong_answers
Severity: Minor
Found in app/models/question.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 toggle_admin has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

  def toggle_admin(id, status)
    if id == self.id
      return "Cannot unadmin yourself"
    else
      other_user = User.find_by_id(id)
Severity: Minor
Found in app/models/user.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 diff_db has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def diff_db(qset_json)
        diffs = []
        qset_json.each do |qset_name, question_json|
            question_set = QuestionSet.find_by_name(qset_name)
            if not question_set
Severity: Minor
Found in features/support/seed_helper.rb - About 1 hr to fix

    Method import has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.import(csv_path)
            rows = CSV.read(csv_path)
            if not self.verify_first_line(rows[0])
                return false
            end
    Severity: Minor
    Found in app/models/tag.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 cross_check_diffs has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def self.cross_check_diffs(file_qsets)
            #Returns a hash of answers, edits, deletions. Answers and edits contains 
            #a message, which may be an empty string if we do not want to create a new message
            edits = {}
            additions = {}
    Severity: Minor
    Found in app/models/question_set.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 find_edits has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def find_edits(wrong_answer_list)
            db_display_list = {} # wrong answers shown (edited or deleted)
            upload_display_list = {} #wrong answers shown (edited or added)
            
            db_wrong_answer_list = self.wrong_answers
    Severity: Minor
    Found in app/models/question.rb - About 1 hr to fix

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

          def self.cross_check_diffs(file_t2c)
              #Returns a hash of additions and deletions.
              #Note the instances are in json form
              additions = []
              deletions = []
      Severity: Minor
      Found in app/models/tag2concept.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 seed_db has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

        def seed_db(qset_json)
          # seed db with qsets in json, expect it to be in same format as question.json
          # also assumes an empty database except for tags (doesn't check for new questions, qsets, or was)
          # so all tags in the seed json should be within tag1-tag10
          qset_json.each do |qset_name, question_json|
      Severity: Minor
      Found in features/support/seed_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 import has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def self.import(csv_path)
              rows = CSV.read(csv_path)
              if not self.verify_first_line(rows[0])
                  return false
              end
      Severity: Minor
      Found in app/models/tag2concept.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 aggregate_changes has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def aggregate_changes
          changes = {}
          confirmed_additions = params[:confirmed_additions]
          additions = []
          if confirmed_additions
      Severity: Minor
      Found in app/controllers/application_controller.rb - About 1 hr to fix

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

          def sort_messages(sort_type, messages, is_hint)
            message_upvotes = {}
            message_downvotes = {}
            messages.each do |message|
                upvotes = 0
        Severity: Minor
        Found in app/controllers/application_controller.rb - About 1 hr to fix

          Method sort_messages has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def sort_messages(sort_type, messages, is_hint)
              message_upvotes = {}
              message_downvotes = {}
              messages.each do |message|
                  upvotes = 0
          Severity: Minor
          Found in app/controllers/application_controller.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

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

              def self.import(csv_path)
                  rows = CSV.read(csv_path)
                  if not self.verify_first_line(rows[0])
                      return false
                  end
          Severity: Minor
          Found in app/models/concept.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 cross_check_diffs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.cross_check_diffs(file_concepts)
                  #Returns a hash of answers, edits, deletions. Answers and edits contains 
                  #a message, which may be an empty string if we do not want to create a new message
                  #Note the instances are in json form
                  edits = []
          Severity: Minor
          Found in app/models/concept.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 cross_check_diffs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.cross_check_diffs(file_tags)
                  #Returns a hash of answers, edits, deletions. Answers and edits contains 
                  #a message, which may be an empty string if we do not want to create a new message
                  #Note the instances are in json form
                  edits = []
          Severity: Minor
          Found in app/models/tag.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 import has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.import(current_user, file)
              
              first_line = file.readline
              if not self.verify_first_line(first_line)
                  return "Users file not correctly formatted. First 2 columns must be Name, Email"
          Severity: Minor
          Found in app/models/user.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 find_additions_and_edits has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.find_additions_and_edits(question_hash, upload_display_list, db_display_list)
                  question_hash.each do |question_text, wa_hash|
                      question = Question.find_by_text(question_text)
                      if not question
                          # addition of question
          Severity: Minor
          Found in app/models/question_set.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 make_edit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def self.make_edit(exist_concept, upload_concept)
                  #Check if there's an edit. If so, change it but don't save
                  #Otherwise return False
                  new_description, new_message = upload_concept
                  edit = [exist_concept, ""]
          Severity: Minor
          Found in app/models/concept.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

          Severity
          Category
          Status
          Source
          Language