noobling/anglicare-sprint-week

View on GitHub
app_server/controllers/service.js

Summary

Maintainability
F
1 wk
Test Coverage

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

    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 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

          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 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 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 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 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 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

                    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 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 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 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 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

                            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

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return {
                                                        label: 'SECURE',
                                                        name: 'SECURE',
                                                        icon: 'lock',
                                                      };
                                                  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: 'NO SMOKING',
                                                            name: 'SMOKE',
                                                            icon: 'smoke_free',
                                                          };
                                                    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: 'GYM',
                                                            name: 'GYM',
                                                            icon: 'fitness_center',
                                                          };
                                                      Severity: Major
                                                      Found in app_server/controllers/service.js - About 30 mins to fix

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                            Service.findOneAndUpdate(
                                                              { uri: req.params.serviceUri },
                                                              { $push: { img: req.file.storageObject } },
                                                              { runValidators: true },
                                                            ).exec()
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 6 hrs to fix
                                                        app_server/controllers/service.js on lines 821..839

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 173.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                            Service.findOneAndUpdate(
                                                              { uri: req.params.serviceUri },
                                                              { $set: { logo: req.file.storageObject } },
                                                              { runValidators: true },
                                                            ).exec()
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 6 hrs to fix
                                                        app_server/controllers/service.js on lines 777..795

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 173.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                              if (canAccessDashboard(req.user, service[0]._id)) {
                                                                Request.find(
                                                                  {
                                                                    _id: service[0].requests,
                                                                  },
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 3 hrs to fix
                                                        app_server/controllers/service.js on lines 478..496

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 109.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                              if (canAccessDashboard(req.user, service[0]._id)) {
                                                                Request.find(
                                                                  {
                                                                    _id: service[0].openRequests,
                                                                  },
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 3 hrs to fix
                                                        app_server/controllers/service.js on lines 510..528

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 109.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                              if (req.body.id === 'BATHSHARED') {
                                                                console.log('executing bath shared')
                                                                const bathPrivate = findAmenityToUpdate('BATHPRIVATE');
                                                                Service.findOneAndUpdate({ uri: req.params.serviceUri }, { $pull: {amenities: bathPrivate}}, (err, service) => {
                                                                  if (err) console.log(err);
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 2 hrs to fix
                                                        app_server/controllers/service.js on lines 974..980

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 87.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                              } else if (req.body.id === 'BATHPRIVATE') {
                                                                console.log('executing bath private')
                                                                const bathShared = findAmenityToUpdate('BATHSHARED');
                                                                Service.findOneAndUpdate({ uri: req.params.serviceUri }, { $pull: { amenities: bathShared } }, (err, service) => {
                                                                  if (err) console.log(err);
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 2 hrs to fix
                                                        app_server/controllers/service.js on lines 968..980

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 87.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                          googleMapsClient.geocode({ address: req.body.serveSuburb.concat(', ').concat(req.body.serveState).concat(', ').concat(req.body.serveState) }).asPromise()
                                                            .then((response) => {
                                                              const temp = response.json.results[0].geometry.location;
                                                        
                                                              service.name = req.body.serveName;
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 2 hrs to fix
                                                        app_server/controllers/service.js on lines 378..385

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 83.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                            googleMapsClient.geocode({ address: req.body.serveSuburb.concat(', ').concat(req.body.serveState).concat(', ').concat(req.body.serveState) }).asPromise()
                                                              .then((response) => {
                                                                console.log(response.json.results[0].geometry.location);
                                                                const coords = response.json.results[0].geometry.location;
                                                                Service.findOneAndUpdate({ name: req.params.serviceName }, { $set: { 'address.coordinates.coordinates': [coords.lng, coords.lat] } }, (err) => {
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 2 hrs to fix
                                                        app_server/controllers/service.js on lines 271..333

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 83.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                          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(
                                                              { uri: req.params.serviceUri },
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 2 hrs to fix
                                                        app_server/controllers/service.js on lines 819..854

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 76.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                          if (req.file && req.file.storageObject) {
                                                            // Get the corresponding Service from the serviceUri and update the logo reference
                                                            Service.findOneAndUpdate(
                                                              { uri: req.params.serviceUri },
                                                              { $set: { logo: req.file.storageObject } },
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 2 hrs to fix
                                                        app_server/controllers/service.js on lines 774..810

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 76.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                          if (service.SMOKE === 'on') {
                                                            amen.push({
                                                              label: 'SMOKING',
                                                              name: 'SMOKE',
                                                              icon: 'smoking_rooms',
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 1 hr to fix
                                                        app_server/controllers/service.js on lines 36..48

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 73.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                          if (service.BATH === 'private') {
                                                            amen.push({
                                                              label: 'BATHROOM PRIVATE',
                                                              name: 'BATHPRIVATE',
                                                              icon: 'wc',
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 1 hr to fix
                                                        app_server/controllers/service.js on lines 49..61

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 73.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                        module.exports.userSettings = (req, res) => {
                                                          if (!req.user) return res.status(401).render('index');
                                                        
                                                          return res.render('userSettings');
                                                        };
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 1 hr to fix
                                                        app_server/controllers/service.js on lines 1005..1009

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 62.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                        module.exports.userService = (req, res) => {
                                                          if (!req.user) return res.status(401).render('index');
                                                        
                                                          return res.render('userService');
                                                        };
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 1 hr to fix
                                                        app_server/controllers/service.js on lines 999..1003

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 62.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                            Promise.all([
                                                              images.getImagesForService(service, req.params.serviceUri),
                                                              images.getImageForService(service.logo, req.params.serviceUri),
                                                            ]).then(([imgs, logo]) => {
                                                              const params = imgs;
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 1 hr to fix
                                                        app_server/controllers/service.js on lines 928..936

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 55.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                                        Open

                                                            Promise.all([
                                                              images.getImagesForService(service, req.params.serviceUri),
                                                              images.getImageForService(service.logo, req.params.serviceUri),
                                                            ]).then(([imgs, logo]) => {
                                                              const params = imgs;
                                                        Severity: Major
                                                        Found in app_server/controllers/service.js and 1 other location - About 1 hr to fix
                                                        app_server/controllers/service.js on lines 906..913

                                                        Duplicated Code

                                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                                        Tuning

                                                        This issue has a mass of 55.

                                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                        Refactorings

                                                        Further Reading

                                                        There are no issues that match your filters.

                                                        Category
                                                        Status