volontariat/voluntary

View on GitHub

Showing 146 of 242 total issues

Avoid deeply nested control flow statements.
Open

              if (set.offsetSign === '-') {
                set.offsetMinutes *= -1;
              }
Severity: Major
Found in app/assets/javascripts/voluntary/lib/sugar.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                                  unless (@result.new_record? rescue true)
                                    results.item(:show, @result.name, result_path(@result)) do |result|
                                      if can? :destroy, @result
                                        result.item :destroy, I18n.t('general.destroy'), result_path(@result), method: :delete, confirm: I18n.t('general.questions.are_you_sure')
                                      end
    Severity: Major
    Found in lib/voluntary/navigation.rb - About 45 mins to fix

      Function abbreviateNumber has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        function abbreviateNumber(num, roundTo, str, mid, limit, bytes) {
      Severity: Minor
      Found in app/assets/javascripts/voluntary/lib/sugar.js - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                      if (set.shift) {
                        // Shift and unit, ie "next month", "last week", etc.
                        num *= (tmp = loc.modifiersByName[set.shift]) ? tmp.value : 0;
                      }
        Severity: Major
        Found in app/assets/javascripts/voluntary/lib/sugar.js - About 45 mins to fix

          Consider simplifying this complex logical expression.
          Open

                if (obj.start && obj.end) {
                  return obj.start >= this.start && obj.start <= this.end &&
                         obj.end   >= this.start && obj.end   <= this.end;
                } else {
                  return obj >= this.start && obj <= this.end;
          Severity: Major
          Found in app/assets/javascripts/voluntary/lib/sugar.js - About 40 mins to fix

            Function createDate has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              function createDate(contextDate, f, localeCode, prefer, forceUTC) {
            Severity: Minor
            Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

              Function addFormat has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  addFormat: function(src, allowsTime, match, variant, iso) {
              Severity: Minor
              Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                Function compareDate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                  function compareDate(d, find, localeCode, buffer, forceUTC) {
                Severity: Minor
                Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                  Function extend has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                    function extend(klass, methods, instance, polyfill, override) {
                  Severity: Minor
                  Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                    Function getExtendedDate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                      function getExtendedDate(contextDate, f, localeCode, prefer, forceUTC) {
                    Severity: Minor
                    Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                      Function truncateString has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                        function truncateString(str, length, from, ellipsis, split) {
                      Severity: Minor
                      Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                        Function runTagReplacements has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                          function runTagReplacements(str, reg, strip, replacementFn, fullString) {
                        Severity: Minor
                        Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                          Function entryAtIndex has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                            function entryAtIndex(obj, length, index, overshoot, isString) {
                          Severity: Minor
                          Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                            Function setDelay has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                              function setDelay(fn, ms, after, scope, args) {
                            Severity: Minor
                            Found in app/assets/javascripts/voluntary/lib/sugar.js - About 35 mins to fix

                              Method languages has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def self.languages(query = nil)
                                  options = []
                                  
                                  AVAILABLE_LANGUAGES.merge(OTHER_LANGUAGES).each do |locale, language|
                                    next if query && !language.downcase.match(query.downcase)
                              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 access_denied has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                    def access_denied
                                      message = I18n.t('general.exceptions.access_denied')
                                      
                                      if request.format.try('json?') || request.xhr?
                                        render status: 403, json: { error: message } and return
                              Severity: Minor
                              Found in app/controllers/concerns/voluntary/v1/base_controller.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 search has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def self.search(term, known_things)
                                  begin
                                    JSON.parse(
                                      HTTParty.get(
                                        "https://www.wikidata.org/w/api.php?action=wbsearchentities&search=" +
                              Severity: Minor
                              Found in app/models/wikidata.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 build_result has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def build_result
                                  result_params = params[:task] ? params[:task].delete(:result_attributes) : nil
                                  result_params = result_params || {}
                                  
                                  unless resource.result_id.present?
                              Severity: Minor
                              Found in app/controllers/workflow/tasks_controller.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 next has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                def next
                                  story = Story.find(params[:story_id])
                                  task = story.next_task_for_user(current_user)
                                  product_id = story.product_id.blank? ? 'no-name' : story.product_id
                                  
                              Severity: Minor
                              Found in app/controllers/workflow/tasks_controller.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 exception_action has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                              Open

                                        def exception_action(exception)
                                          @exception_catched = true
                                          
                                          if Rails.env == 'production'
                                            notify_airbrake(exception)
                              Severity: Minor
                              Found in lib/applicat/mvc/controller.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

                              Severity
                              Category
                              Status
                              Source
                              Language