pupilfirst/pupilfirst

View on GitHub

Showing 53 of 103 total issues

File rollbar.js has 399 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var _rollbarConfig = {
  accessToken: process.env.ROLLBAR_CLIENT_TOKEN,
  captureUncaught: process.env.ROLLBAR_CAPTURE_UNCAUGHT === "true",
  captureUnhandledRejections:
    process.env.ROLLBAR_CAPTURE_UNHANDLED_REJECTIONS === "true",
Severity: Minor
Found in app/javascript/shared/utils/rollbar.js - About 5 hrs to fix

    Function exports has 99 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = function (api) {
      var validEnv = ["development", "test", "production"];
      var currentEnv = api.env();
      var isDevelopmentEnv = api.env("development");
      var isProductionEnv = api.env("production");
    Severity: Major
    Found in babel.config.js - About 3 hrs to fix

      Class LeaderboardPresenter has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class LeaderboardPresenter < ApplicationPresenter
          class Student < SimpleDelegator
            attr_reader :score, :rank
            attr_accessor :delta
      
      
      Severity: Minor
      Found in app/presenters/courses/leaderboard_presenter.rb - About 2 hrs to fix

        Class Target has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

        class Target < ApplicationRecord
          # Use to allow changing visibility of a target. See Targets::UpdateVisibilityService.
          attr_accessor :safe_to_change_visibility
        
          # Need to allow these two to be read for AA form.
        Severity: Minor
        Found in app/models/target.rb - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                  if (r) {
                    var o = e.globalAlias || "Rollbar";
                    if ("object" == typeof r[o]) return r[o];
                    (r._rollbarShims = {}), (r._rollbarWrappedError = null);
                    var a = new s(e);
          Severity: Critical
          Found in app/javascript/shared/utils/rollbar.js - About 2 hrs to fix

            Function wrap has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  (l.prototype.wrap = function(r, e, o) {
                    try {
                      var n;
                      if (
                        ((n =
            Severity: Minor
            Found in app/javascript/shared/utils/rollbar.js - About 1 hr to fix

              Function loadFull has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  (l.prototype.loadFull = function(r, e, o, n, a) {
                    var l = !1,
                      i = e.createElement("script"),
                      d = e.getElementsByTagName("script")[0],
                      s = d.parentNode;
              Severity: Minor
              Found in app/javascript/shared/utils/rollbar.js - About 1 hr to fix

                Function Home has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function Home() {
                  const context = useDocusaurusContext();
                  const { siteConfig = {} } = context;
                  return (
                    <Layout description="Description will go into a meta tag in <head />">
                Severity: Minor
                Found in docs/developers/src/pages/index.js - About 1 hr to fix

                  Consider simplifying this complex logical expression.
                  Open

                            if (
                              !r._rollbar_wrapped &&
                              ((r._rollbar_wrapped = function() {
                                o && "function" == typeof o && o.apply(this, arguments);
                                try {
                  Severity: Critical
                  Found in app/javascript/shared/utils/rollbar.js - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if (r) {
                              "function" == typeof r._rollbarURH &&
                                r._rollbarURH.belongsToShim &&
                                r.removeEventListener("unhandledrejection", r._rollbarURH);
                              var n = function(r) {
                    Severity: Critical
                    Found in app/javascript/shared/utils/rollbar.js - About 1 hr to fix

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

                          def courses
                            if current_school_admin.present?
                              # All courses are available to admins.
                              current_school.courses
                            else
                      Severity: Minor
                      Found in app/presenters/layouts/student_course_presenter.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

                      Function setupShim has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                            setupShim: function(r, e) {
                              if (r) {
                                var o = e.globalAlias || "Rollbar";
                                if ("object" == typeof r[o]) return r[o];
                                (r._rollbarShims = {}), (r._rollbarWrappedError = null);
                      Severity: Minor
                      Found in app/javascript/shared/utils/rollbar.js - About 1 hr to fix

                        Function onreadystatechange has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                                (i.onload = i.onreadystatechange = t(function() {
                                  if (
                                    !(
                                      l ||
                                      (this.readyState &&
                        Severity: Minor
                        Found in app/javascript/shared/utils/rollbar.js - About 1 hr to fix

                          Function captureUnhandledRejections has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                captureUnhandledRejections: function(r, e, o) {
                                  if (r) {
                                    "function" == typeof r._rollbarURH &&
                                      r._rollbarURH.belongsToShim &&
                                      r.removeEventListener("unhandledrejection", r._rollbarURH);
                          Severity: Minor
                          Found in app/javascript/shared/utils/rollbar.js - About 1 hr to fix

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

                                def sanitize_students(students)
                                  team_sizes = {}
                            
                                  students.select do |student|
                                    if student.team_name.present?
                            Severity: Minor
                            Found in app/services/courses/add_students_service.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 execute has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def execute
                                debug_value = {}
                                updates = topics_from_today
                                updates = add_topics_with_no_activity(updates)
                            
                            
                            Severity: Minor
                            Found in app/services/daily_digest_service.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 authorized? has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                              def authorized?
                                return false if current_user.blank?
                            
                                # Has access to school
                                return false unless course&.school == current_school && founder.present?
                            Severity: Minor
                            Found in app/queries/concerns/authorize_student.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 post has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def post(message:, **target)
                                  log "Posting message to target: #{target.keys}"
                            
                                  if self.class.mock?
                                    log "Skipping post because of @mock flag. Message was: '#{message}'"
                            Severity: Minor
                            Found in app/services/public_slack/message_service.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 create_quiz has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def create_quiz(targets)
                                  targets.each do |old_target, new_target|
                                    next unless old_target.quiz?
                            
                                    # create quiz
                            Severity: Minor
                            Found in app/services/courses/clone_service.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 execute has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                            Open

                                def execute(period_from, period_to)
                                  founders = @course.founders.active.where(excluded_from_leaderboard: false)
                                  log("Recording leaderboard entries for #{founders.count} students in Course##{@course.id}...")
                            
                                  LeaderboardEntry.transaction do
                            Severity: Minor
                            Found in app/services/courses/create_leaderboard_entries_service.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

                            Severity
                            Category
                            Status
                            Source
                            Language