noobling/anglicare-sprint-week

View on GitHub

Showing 64 of 226 total issues

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

module.exports.dashboardOpenRequests = (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 deleteImageFromService has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function deleteImageFromService(service, serviceUri, index) {
      return new Promise((resolve, reject) => {
        // Delete the image specified by 'index' from Firebase
        bucket.file(service.img[index]).delete().then(() => {
          // After deleting the image from Firebase, delete the image from MongoDB
    Severity: Minor
    Found in app_server/middleware/images.js - About 1 hr to fix

      Function index has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports.index = (req, res) => {
        // https://caolan.github.io/async/
        async.parallel(
          {
            crisis: (callback) => { findService(callback, 'crisis'); },
      Severity: Minor
      Found in app_server/controllers/index.js - About 1 hr to fix

        Function submitPhoneNumber has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function submitPhoneNumber (form)
        {
          localStorage.number = form.elements.number.value; 
          localStorage.email = form.elements.email.value; 
          Array.from(document.forms).forEach(function(f) {
        Severity: Minor
        Found in public/javascripts/src/requests.js - About 1 hr to fix

          Function register has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.register = (req, res, next) => {
            if (!req.body.fName
              || !req.body.lName
              || !req.body.email
              || !req.body.pwd
          Severity: Minor
          Found in app_server/controllers/authentication.js - 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

          Function updateAmenities has a Cognitive Complexity of 9 (exceeds 5 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 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

          Function addPagination has a Cognitive Complexity of 8 (exceeds 5 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 45 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

          Function addPagination has a Cognitive Complexity of 8 (exceeds 5 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 45 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

          Function notification has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          module.exports.notification = (number, email, message, subject, res, options) => {
            if (email !== undefined) {
              sendEmail(email, subject, message, res);
            }
          
          
          Severity: Minor
          Found in app_server/controllers/communications.js - About 45 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

          Avoid deeply nested control flow statements.
          Open

                    if (err) console.log(err);
          Severity: Major
          Found in app_server/controllers/service.js - About 45 mins to fix

            Avoid too many return statements within this function.
            Open

                  return {
                    label: 'SMOKING',
                    name: 'SMOKE',
                    icon: 'smoking_rooms',
                  };
            Severity: Major
            Found in app_server/controllers/service.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return {
                    label: 'KITCHEN',
                    name: 'KITCHEN',
                    icon: 'local_dining',
                  };
              Severity: Major
              Found in app_server/controllers/service.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return {
                      label: 'CURFEW',
                      name: 'CURFEW',
                      icon: 'schedule',
                    };
                Severity: Major
                Found in app_server/controllers/service.js - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                      return {
                        label: 'OUTDOOR/GARDEN',
                        name: 'OUTDOOR',
                        icon: 'local_florist',
                      };
                  Severity: Major
                  Found in app_server/controllers/service.js - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                        return {
                          label: 'GAMES/CONSOLE',
                          name: 'GAMES',
                          icon: 'videogame_asset',
                        };
                    Severity: Major
                    Found in app_server/controllers/service.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return {
                            label: 'STUDY',
                            name: 'STUDY',
                            icon: 'local_library',
                          };
                      Severity: Major
                      Found in app_server/controllers/service.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                            return {
                              label: 'BATHROOM SHARED',
                              name: 'BATHSHARED',
                              icon: 'wc',
                            };
                        Severity: Major
                        Found in app_server/controllers/service.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                              return {
                                label: 'AIR-CONDITIONING',
                                name: 'AIRCON',
                                icon: 'ac_unit',
                              };
                          Severity: Major
                          Found in app_server/controllers/service.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                              return false;
                            Severity: Major
                            Found in app_server/controllers/service.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                  return {
                                    label: 'PHONE',
                                    name: 'PHONE',
                                    icon: 'phone',
                                  };
                              Severity: Major
                              Found in app_server/controllers/service.js - About 30 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language