ministryofjustice/prison-visits

View on GitHub

Showing 17 of 29 total issues

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

module.exports = function(grunt) {

  'use strict';

  // Project configuration.
Severity: Major
Found in Gruntfile.js - About 4 hrs to fix

    Function time_slots has 89 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          var time_slots = this.evaluate(function () {
    
            var nodes, slots = {};
    
            // filter-out text nodes
    Severity: Major
    Found in scripts/visiting_times.js - About 3 hrs to fix

      Function displayPerformanceLineChart has 78 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function displayPerformanceLineChart(where, percentile95data, percentile50data, volumeData) {
          var xRange = [new Date(thisYear() - 1, 11, 29), new Date(thisYear() + 1, 0, 1)];
          var y1Range = [0, 1.3 * d3.max(percentile95data, function(d) { return parseInt(d.y); })];
          var y2Range = [0, 1.3 * d3.max(volumeData, function(d) { return parseInt(d.y); })];
      
      
      Severity: Major
      Found in app/assets/javascripts/metrics.js - About 3 hrs to fix

        Function displayHistogram has 77 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function displayHistogram(where, dataSource, displayLines) {
            var width, height, x, y, n, data, maxY, svg, bars, xAxis, medianValue, percentileValue;
        
            width = 960 - margin.left - margin.right;
            height = 500 - margin.top - margin.bottom;
        Severity: Major
        Found in app/assets/javascripts/metrics.js - About 3 hrs to fix

          Method compute_error has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

            def compute_error
              return :unparseable unless parsed
              return :domain_dot if domain_dot_error?
              return :bad_domain if bad_domain?
              return :malformed unless well_formed_address?
          Severity: Minor
          Found in app/services/email_checker.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 _createAutocomplete has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              _createAutocomplete: function(){
                var selected = this.$select.children(':selected'),
                    val = selected.val() ? selected.text() : '',
                    key, value, i, attrs, raw_attrs;
          
          
          Severity: Minor
          Found in app/assets/javascripts/modules/moj.autocomplete.js - About 1 hr to fix

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

              def refresh
                @min_week = 55
                @max_week = 0
                hash_with_default = Hash.new { |h, k| h[k] = Array.new(52, 0) }
            
            
            Severity: Minor
            Found in app/reports/weekly_confirmations_report.rb - About 1 hr to fix

              Function formatSeconds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function formatSeconds(s) {
                  var output = [],
                      d, h, m;
              
                  if (s === 0) {
              Severity: Minor
              Found in app/assets/javascripts/metrics.js - 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 booking_receipt_email has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def booking_receipt_email(visit, confirmation)
                  @visit = visit
                  @confirmation = confirmation
              
                  if confirmation.slot_selected?
              Severity: Minor
              Found in app/mailers/prison_mailer.rb - About 1 hr to fix

                Avoid too many return statements within this method.
                Open

                      return :spam_reported if spam_reported?(parsed.address)
                Severity: Major
                Found in app/services/email_checker.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                        return :bounced if bounced?(parsed.address)
                  Severity: Major
                  Found in app/services/email_checker.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                        return :no_mx_record unless mx_records?
                    Severity: Major
                    Found in app/services/email_checker.rb - About 30 mins to fix

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

                        def update_entry(visit_id)
                          entry = find_entry(visit_id)
                          if entry
                            yield entry
                            entry.save! if entry.changed?
                      Severity: Minor
                      Found in app/services/metrics_logger.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 validate_renewals has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def validate_renewals
                          if outcome == NO_ALLOWANCE
                            if no_vo.present? && renew_vo.blank?
                              errors.add(:no_vo, 'a renewal date must be chosen')
                            end
                      Severity: Minor
                      Found in app/models/confirmation.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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def update
                          visit.visitors = build_visitors
                      
                          go_forward = visit.visitors.all?(&:valid?) && visit.valid?(:visitors_set)
                      
                      
                      Severity: Minor
                      Found in app/controllers/visitors_details_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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def create
                          @feedback = Feedback.new(feedback_params)
                          @feedback.prison = prison_name if visit
                      
                          if @feedback.valid?
                      Severity: Minor
                      Found in app/controllers/feedbacks_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 parse has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                        def self.parse(hash)
                          hash = hash.dup
                          raise ParseError.new("Missing subject") unless hash[:subject]
                          raise ParseError.new("Missing email body") unless hash[:text]
                          charsets = JSON.parse(hash[:charsets]).with_indifferent_access
                      Severity: Minor
                      Found in app/models/parsed_email.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