noobling/anglicare-sprint-week

View on GitHub

Showing 64 of 226 total issues

Function updateService has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports.updateService = (req, res) => {
  if (!req.user) {
    return res.status(401).json({ message: 'You must be logged in to create a new service provider.' });
  }

Severity: Minor
Found in app_server/controllers/service.js - About 1 hr to fix

    Function createImages has a Cognitive Complexity of 14 (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/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 updateAmenities has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.updateAmenities = (req, res) => {
      const amenity = findAmenityToUpdate(req.body.id, req.body.checkedState);   
      if (amenity) {
        if (req.body.checkedState === 'true') {
          Service.findOneAndUpdate({ uri: req.params.serviceUri }, {
    Severity: Minor
    Found in app_server/controllers/service.js - About 1 hr to fix

      Function seedAccomm has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function seedAccomm(numToGen) {
        for (let i = 0; i < numToGen; i += 1) {
          const randNum = randInt(0, SUBURBS.length);
      
          const address = {
      Severity: Minor
      Found in generate.seed.services.js - About 1 hr to fix

        Function bedsAvailable has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

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

          Function geoloc has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function geoloc()
          {
              const oldLocValue = document.getElementById('location').value;
              document.getElementById('location').value = 'Finding your location ...';
          
          
          Severity: Minor
          Found in public/javascripts/src/location.js - About 1 hr to fix

            Function sendUploadToFirebase has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function sendUploadToFirebase(req, res, next) {
              if (!req.file) {
                return next();
              }
            
            
            Severity: Minor
            Found in app_server/middleware/images.js - About 1 hr to fix

              Function showLocation has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              module.exports.showLocation = (req, res) => {
                Service.findOne(
                  { uri: req.params.serviceUri },
                  'name description address amenities houseRules about img logo hours thankyouMessage stayLength',
                ).exec().then((service) => {
              Severity: Minor
              Found in app_server/controllers/locations.js - About 1 hr to fix

                Function seedUsers has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function seedUsers() {
                  for (let i = 0; i < NUM_USERS; i += 1) {
                    const year = Math.floor(2003 - randInt(0, 10)); // 15 to 25 y.o. as of 2018
                    const month = randInt(1, 12);
                    const day = randInt(1, 30);
                Severity: Minor
                Found in generate.seed.data.js - About 1 hr to fix

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

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

                    Consider simplifying this complex logical expression.
                    Open

                      if (!req.body.fName
                        || !req.body.lName
                        || !req.body.email
                        || !req.body.pwd
                        || !req.body.day
                    Severity: Critical
                    Found in app_server/controllers/authentication.js - About 1 hr to fix

                      Consider simplifying this complex logical expression.
                      Open

                              if (fname > 0 && lname > 0 && email > 0 && pass.length > 0 && con == pass && dob && gen > 0 && bool) $('#Reg').prop('disabled', false);else $('#Reg').prop('disabled', true);
                      Severity: Critical
                      Found in public/javascripts/validation.js - About 1 hr to fix

                        Consider simplifying this complex logical expression.
                        Open

                            if (fname > 0 && lname > 0 && email > 0 && pass.length > 0 && con == pass && dob && gen > 0 && bool)
                                $('#Reg').prop('disabled', false);
                            else
                                $('#Reg').prop('disabled', true);
                        Severity: Critical
                        Found in public/javascripts/src/validation.js - About 1 hr to fix

                          Function genOpeningHours has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          function genOpeningHours() {
                            const startHours = choose(START_HOURS);
                            const endHours = choose(END_HOURS);
                            return {
                              mon: {
                          Severity: Minor
                          Found in generate.seed.services.js - About 1 hr to fix

                            Function uploadLogo has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            module.exports.uploadLogo = (req, res) => {
                              if (req.file && req.file.storageObject) {
                                // Get the corresponding Service from the serviceUri and update the logo reference
                                Service.findOneAndUpdate(
                                  { uri: req.params.serviceUri },
                            Severity: Minor
                            Found in app_server/controllers/service.js - About 1 hr to fix

                              Function uploadImage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                              module.exports.uploadImage = (req, res) => {
                                if (req.file && req.file.storageObject) {
                                  // Get the corresponding Service from the serviceUri and push the image
                                  // reference to the list of images
                                  Service.findOneAndUpdate(
                              Severity: Minor
                              Found in app_server/controllers/service.js - About 1 hr to fix

                                Function geoloc has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                                Open

                                function geoloc() {
                                  var oldLocValue = document.getElementById('location').value;
                                  document.getElementById('location').value = 'Finding your location ...';
                                
                                  if (!navigator.geolocation) {
                                Severity: Minor
                                Found in public/javascripts/location.js - About 1 hr to fix

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

                                  function getImagesForService(service, serviceUri) {
                                    return new Promise((resolve, reject) => {
                                      let metadataCount = 0;
                                      let listCount = 0;
                                      const imageDict = [];
                                  Severity: Minor
                                  Found in app_server/middleware/images.js - About 1 hr to fix

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

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

                                      Function addPagination has 28 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/service.js - About 1 hr to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language