cityssm/mini-shop-db

View on GitHub

Showing 8 of 29 total issues

Function _getOrders has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring.
Open

export const _getOrders = async (config, filters) => {
    try {
        const pool = await sqlPool.connect(config.mssqlConfig);
        let sql = "select o.orderID, o.orderNumber, o.orderTime," +
            " o.shippingName, o.shippingAddress1, o.shippingAddress2, o.shippingCity, o.shippingProvince, o.shippingCountry, o.shippingPostalCode," +
Severity: Minor
Found in getOrders.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 _getOrders has a Cognitive Complexity of 22 (exceeds 15 allowed). Consider refactoring.
Open

export const _getOrders = async (config: MiniShopConfig,
  filters: GetOrderFilters): Promise<Order[]> => {

  try {
    const pool = await sqlPool.connect(config.mssqlConfig);
Severity: Minor
Found in getOrders.ts - 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 _getOrders has 106 lines of code (exceeds 100 allowed). Consider refactoring.
Open

export const _getOrders = async (config, filters) => {
    try {
        const pool = await sqlPool.connect(config.mssqlConfig);
        let sql = "select o.orderID, o.orderNumber, o.orderTime," +
            " o.shippingName, o.shippingAddress1, o.shippingAddress2, o.shippingCity, o.shippingProvince, o.shippingCountry, o.shippingPostalCode," +
Severity: Major
Found in getOrders.js - About 1 hr to fix

    Function _getOrders has 105 lines of code (exceeds 100 allowed). Consider refactoring.
    Open

    export const _getOrders = async (config: MiniShopConfig,
      filters: GetOrderFilters): Promise<Order[]> => {
    
      try {
        const pool = await sqlPool.connect(config.mssqlConfig);
    Severity: Major
    Found in getOrders.ts - About 1 hr to fix

      Function _getOrder has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
      Open

      export const _getOrder = async (config: MiniShopConfig,
        orderNumber: string, orderSecret: string, orderIsPaid: boolean, enforceExpiry = true) => {
      
        try {
          const pool = await sqlPool.connect(config.mssqlConfig);
      Severity: Minor
      Found in getOrder.ts - 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 _getOrder has a Cognitive Complexity of 19 (exceeds 15 allowed). Consider refactoring.
      Open

      export const _getOrder = async (config, orderNumber, orderSecret, orderIsPaid, enforceExpiry = true) => {
          try {
              const pool = await sqlPool.connect(config.mssqlConfig);
              const orderResult = await pool.request()
                  .input("orderNumber", orderNumber)
      Severity: Minor
      Found in getOrder.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 too many return statements within this function.
      Open

        return false;
      Severity: Major
      Found in updateOrderAsPaid.ts - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return false;
        Severity: Major
        Found in updateOrderAsPaid.js - About 30 mins to fix
          Severity
          Category
          Status
          Source
          Language