crowdAI/crowdai

View on GitHub

Showing 97 of 178 total issues

Avoid too many return statements within this method.
Open

    return false # no positive condition met
Severity: Major
Found in app/policies/challenge_policy.rb - About 30 mins to fix

    Avoid too many return statements within this method.
    Open

          return false
    Severity: Major
    Found in app/controllers/api/external_graders_controller.rb - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                return innerText.replace(/^\s+|\s+$/g, '');
      Severity: Major
      Found in app/assets/javascripts/modules/sorttable.js - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

              return youtube
        Severity: Major
        Found in app/concepts/leaderboard/cells/media.rb - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return node.value.replace(/^\s+|\s+$/g, '');
          Severity: Major
          Found in app/assets/javascripts/modules/sorttable.js - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return true #return true if running and no clef challenge
            Severity: Major
            Found in app/policies/challenge_policy.rb - About 30 mins to fix

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

                def get_challenge_round_id(challenge:, params:)
                  if params[:challenge_round_id].present?
                    round = ChallengeRound.where(
                      challenge_id: challenge.id,
                      id: params[:challenge_round_id]).first
              Severity: Minor
              Found in app/controllers/api/external_graders_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 submission_media has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def submission_media(submission_id)
                  submission = Submission.find(submission_id)
                  if submission.media_content_type.present?
                    type = submission.media_content_type.split('/').first
                    if type == 'image'
              Severity: Minor
              Found in app/helpers/leaderboard_videos_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 grading_params has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def grading_params
                  case params[:grading_status]
                  when 'graded'
                    if params[:grading_message].blank?
                      grading_message = 'Graded successfully'
              Severity: Minor
              Found in app/controllers/api/external_graders_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 score has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def score(submission)
                  challenge = submission.challenge
                  if submission.graded?
                    if challenge.secondary_sort_order == 'not_used'
                      return "<li>Mean F1: #{submission.score}</li>".html_safe
              Severity: Minor
              Found in app/helpers/submissions_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

              Function sort_ddmm has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                sort_ddmm: function(a,b) {
                  mtch = a[0].match(sorttable.DATE_RE);
                  y = mtch[3]; m = mtch[2]; d = mtch[1];
                  if (m.length == 1) m = '0'+m;
                  if (d.length == 1) d = '0'+d;
              Severity: Minor
              Found in app/assets/javascripts/modules/sorttable.js - 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 large_submission_media has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def large_submission_media(submission_id)
                  submission = Submission.find(submission_id)
                  if submission.media_content_type.present?
                    type = submission.media_content_type.split('/').first
                    if type == 'image'
              Severity: Minor
              Found in app/helpers/leaderboard_videos_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 remaining_text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def remaining_text
                  if challenge.running?
                    if remaining_time_in_days > 0
                      "#{pluralize(remaining_time_in_days,'day')} left"
                    elsif remaining_time_in_hours > 0
              Severity: Minor
              Found in app/concepts/challenge/cells/challenge_masthead.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 clef_participant_registered? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                def clef_participant_registered?(challenge)
                  return false unless participant.present?
                  clef_task = challenge.clef_task
                  participant_clef_task = ParticipantClefTask.where(
                    participant_id: participant,
              Severity: Minor
              Found in app/policies/challenge_policy.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

              Function forEach has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              var forEach = function(object, block, context) {
                  if (object) {
                      var resolve = Object; // default
                      if (object instanceof Function) {
                          // functions have a "length" property
              Severity: Minor
              Found in app/assets/javascripts/modules/sorttable.js - 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 resolve has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def resolve
                    if participant && participant.admin?
                      scope.all
                    else
                      if participant && participant.organizer_id
              Severity: Minor
              Found in app/policies/participant_challenge_policy.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

              Function sort_mmdd has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                sort_mmdd: function(a,b) {
                  mtch = a[0].match(sorttable.DATE_RE);
                  y = mtch[3]; d = mtch[2]; m = mtch[1];
                  if (m.length == 1) m = '0'+m;
                  if (d.length == 1) d = '0'+d;
              Severity: Minor
              Found in app/assets/javascripts/modules/sorttable.js - 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