spmcbride1201/cookie-monsters

View on GitHub

Showing 5 of 42 total issues

File orders.js has 258 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict'

const db = require('../db')
const Order = require('../db/models/order')
const Product = require('../db/models/product')
Severity: Minor
Found in server/orders.js - About 2 hrs to fix

    Function exports has 44 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        .get('/', (req, res, next) => {
            console.log("get /api/orders/");
            // .get('/', mustBeLoggedIn, (req, res, next) => {
            if (req.user && req.user.isAdmin) {
                console.log("is an admin");
    Severity: Minor
    Found in server/orders.js - About 1 hr to fix

      Function reducer has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      const reducer = (lineItems = [], action) => {
      
        switch (action.type) {
          case ADD_TO_CART:
            console.log("Starting ADD_TO_CART");
      Severity: Minor
      Found in app/reducers/cart.jsx - 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 reducer has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const reducer = (lineItems = [], action) => {
      
        switch (action.type) {
          case ADD_TO_CART:
            console.log("Starting ADD_TO_CART");
      Severity: Minor
      Found in app/reducers/cart.jsx - About 1 hr to fix

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

        export function submitOrder(cart) {
          [
            {
              product: {},
              quantity: 1
        Severity: Minor
        Found in app/reducers/orders.jsx - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language