Billmike/More-Recipes

View on GitHub

Showing 10 of 101 total issues

Function getUserRecipes has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const getUserRecipes = (req, res) => {
  Recipe.findAll({
    where: {
      owner: req.userId
    },
Severity: Minor
Found in server/controllers/getAllRecipes.js - About 1 hr to fix

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

    const validateRecipeAdd = (req, res, next) => {
      const {
        name, description, category, ingredients, instructions,
      } = req.body;
      if (name === undefined || name.trim() === '') {
    Severity: Minor
    Found in server/validators/validateAddRecipe.js - About 1 hr to fix

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

        static modifyRecipe(req, res) {
          return recipes
            .findById(req.params.recipeId)
            .then((recipe) => {
              if (!recipe) {
      Severity: Minor
      Found in server/controllers/recipes.js - About 1 hr to fix

        Function Create a recipe without complete details has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          'Create a recipe without complete details': (client) => {
            client
              .assert.visible('h2.dashboard-h2')
              .assert.containsText(
                'h2.dashboard-h2',
        Severity: Minor
        Found in e2e_tests/dashboard_test.js - About 1 hr to fix

          Function Add and remove Recipe from users favorites has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            'Add and remove Recipe from users favorites': (client) => {
              client.url(`${URL}/dashboard`)
                .waitForElementVisible('body', 7000)
                .click('#home-button')
                .waitForElementPresent('.under-carousel-div', 7000)
          Severity: Minor
          Found in e2e_tests/dashboard_test.js - About 1 hr to fix

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

            const sortRecipes = (recipeArray, sortOrder, callback) => {
              if (recipeArray.length === 0) return recipeArray;
              if (sortOrder !== 'ascending' && sortOrder !== 'descending') {
                const err = new Error('Invalid sorting order.');
                err.status = 400;
            Severity: Minor
            Found in server/controllers/getAllRecipes.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 validateRecipeAdd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            const validateRecipeAdd = (req, res, next) => {
              const {
                name, description, category, ingredients, instructions,
              } = req.body;
              if (name === undefined || name.trim() === '') {
            Severity: Minor
            Found in server/validators/validateAddRecipe.js - About 35 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 validateRecipe has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

            const validateRecipe = (data) => {
              const errors = {};
              if (data.name === undefined || data.name.trim() === '') {
                errors.name = 'Recipe name is required';
              }
            Severity: Minor
            Found in server/validators/validateRecipe.js - About 35 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 too many return statements within this function.
            Open

                return next(err);
            Severity: Major
            Found in server/validators/validateAddRecipe.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                return next();
              Severity: Major
              Found in server/validators/validateAddRecipe.js - About 30 mins to fix
                Severity
                Category
                Status
                Source
                Language