noobling/anglicare-sprint-week

View on GitHub

Showing 64 of 226 total issues

File service.js has 979 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var bedIndex = 0;

$.ajaxSetup({ cache: false })

$('#editBedModal').on('show.bs.modal', function() {
Severity: Major
Found in public/javascripts/src/service.js - About 2 days to fix

    File service.js has 855 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const mongoose = require('mongoose');
    const googleMapsClient = require('@google/maps').createClient({
      key: process.env.embed_maps_api,
      Promise, // 'Promise' is the native constructor.
    });
    Severity: Major
    Found in app_server/controllers/service.js - About 2 days to fix

      File service.js has 799 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
      
      var bedIndex = 0;
      Severity: Major
      Found in public/javascripts/service.js - About 1 day to fix

        Function findAmenityToUpdate has 114 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function findAmenityToUpdate(amenity, status) {
          if (amenity === 'TV') {
            return {
              label: 'TV',
              name: 'TV',
        Severity: Major
        Found in app_server/controllers/service.js - About 4 hrs to fix

          Function amenities has 112 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function amenities(service) {
            const amen = [];
          
            if (service.TV === 'on') {
              amen.push({
          Severity: Major
          Found in app_server/controllers/service.js - About 4 hrs to fix

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

            module.exports.showLocations = (req, res) => {
              const name = req.body.fName + ' ' + req.body.lName;
              const longTerm = (req.params.lengthOfStay === 'long_term');
              const type = (longTerm ? ['transitional'] : ['crisis']);
              const age = parseInt(timeago().format(req.body.dob).split(' ')[0], 10);
            Severity: Major
            Found in app_server/controllers/locations.js - About 3 hrs to fix

              File validation.js has 327 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /**
               * Checks if the #addReview form has data for all 
               * fields if it doesn't then an error message is shown
               * to the user and the form does not submit to the server
               */
              Severity: Minor
              Found in public/javascripts/src/validation.js - About 3 hrs to fix

                Function addPhoneToRequest has 85 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                module.exports.addPhoneToRequest = (req, res) => {
                  if (req.session.requestId) {
                    // Add phone number to request
                    Request.findOneAndUpdate(
                      { _id: req.session.requestId },
                Severity: Major
                Found in app_server/controllers/requests.js - About 3 hrs to fix

                  Function addService has 63 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  module.exports.addService = (req, res, next) => {
                    if (!req.user) {
                      res.status(401).json({ message: 'You must be logged in to create a new service provider.' });
                      return;
                    }
                  Severity: Major
                  Found in app_server/controllers/service.js - About 2 hrs to fix

                    Function findAmenityToUpdate has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function findAmenityToUpdate(amenity, status) {
                      if (amenity === 'TV') {
                        return {
                          label: 'TV',
                          name: 'TV',
                    Severity: Minor
                    Found in app_server/controllers/service.js - 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

                    File validation.js has 267 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    'use strict';
                    
                    /**
                     * Checks if the #addReview form has data for all 
                     * fields if it doesn't then an error message is shown
                    Severity: Minor
                    Found in public/javascripts/validation.js - About 2 hrs to fix

                      Function updateBeds has 59 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      module.exports.updateBeds = (req, res) => {
                        if (!req.user) {
                          res.status(401).json({ message: 'You are not authorised to view this page.' });
                          return;
                        }
                      Severity: Major
                      Found in app_server/controllers/service.js - About 2 hrs to fix

                        Function createImages has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        function createImages(uri, logo, images) {
                          var isIE = false;
                          var ua = window.navigator.userAgent;
                          var msie = ua.indexOf("MSIE ");
                        
                        
                        Severity: Major
                        Found in public/javascripts/src/service.js - About 2 hrs to fix

                          Function createImages has 55 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function createImages(uri, logo, images) {
                            var isIE = false;
                            var ua = window.navigator.userAgent;
                            var msie = ua.indexOf("MSIE ");
                          
                          
                          Severity: Major
                          Found in public/javascripts/service.js - About 2 hrs to fix

                            Function register has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            module.exports.register = (req, res, next) => {
                              if (!req.body.fName
                                || !req.body.lName
                                || !req.body.email
                                || !req.body.pwd
                            Severity: Major
                            Found in app_server/controllers/authentication.js - About 2 hrs to fix

                              Function amenities has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                              Open

                              function amenities(service) {
                                const amen = [];
                              
                                if (service.TV === 'on') {
                                  amen.push({
                              Severity: Minor
                              Found in app_server/controllers/service.js - 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

                              Function updateRequests has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              function updateRequests() {
                                $('#updateRequests > .form-group').html('');
                                $('#updateRequests > .form-group').hide();
                                $('#spinnerLoadRequests').show();
                                $.get('/service/dashboard/' + $('#uri').text() + '/requests/show', function(data) {
                              Severity: Minor
                              Found in public/javascripts/src/service.js - About 1 hr to fix

                                Function updateRequests has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function updateRequests() {
                                  $('#updateRequests > .form-group').html('');
                                  $('#updateRequests > .form-group').hide();
                                  $('#spinnerLoadRequests').show();
                                  $.get('/service/dashboard/' + $('#uri').text() + '/requests/show', function (data) {
                                Severity: Minor
                                Found in public/javascripts/service.js - About 1 hr to fix

                                  Function createImages has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                                  Open

                                  function createImages(uri, logo, images) {
                                    var isIE = false;
                                    var ua = window.navigator.userAgent;
                                    var msie = ua.indexOf("MSIE ");
                                  
                                  
                                  Severity: Minor
                                  Found in public/javascripts/src/service.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

                                  Function addPagination has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  function addPagination(name, services) {
                                    var numSegments = 1;
                                    var numAdded = 0;
                                  
                                    for (var i = 0; i < services.length; i++) {
                                  Severity: Minor
                                  Found in public/javascripts/src/service.js - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language