waiterio/api

View on GitHub

Showing 7 of 569 total issues

Function getLogger has 46 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function getLogger() {
    const loggerObject = new (winston.Logger)({
        levels: {
            trace: 0,
            debug: 1,
Severity: Minor
Found in common/logging.js - About 1 hr to fix

    Function getRepo has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports.getRepo = function(db) {
        return {
            addRecord: function(queryOptions, dbData, callback) {
                const preparedOptions = dbHelpers.prepareQueryOptions(queryOptions);
                const dbQuery = `INSERT INTO ${preparedOptions.table} ${dbData.fieldQuery} VALUES ${dbData.valueQuery}`.trim();
    Severity: Minor
    Found in common/databaseRepository.js - About 1 hr to fix

      Function addOrder has 29 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      module.exports.addOrder = function(req, res) {
          const orderItems = req.body.orderitems;
          const orderData = [
              { field: 'notes', input: req.body.notes, rules: { notEmpty: false, type: 'string' } },
              { field: 'ordertimestamp', input: new Date().getTime().toString(), rules: { notEmpty: true, type: 'string' } },
      Severity: Minor
      Found in api/orders/ordersPost.js - About 1 hr to fix

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

        module.exports.prepareQueryOptions = function(queryOptions) {
            const preparedQueryOptions = queryOptions;
        
            if (typeof preparedQueryOptions !== 'undefined' && preparedQueryOptions !== null) {
                if (typeof queryOptions.fields === 'undefined') {
        Severity: Minor
        Found in common/databaseHelpers.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 exports has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function(req, res, next) {
            req.app.get('log').route(`${req.method} ${req.originalUrl}`);
        
            const accessToken = (req.body && req.body.access_token) || req.headers[ 'access-token' ];
        
        
        Severity: Minor
        Found in auth/validateRequest.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 exports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = function(options) {
            options.database = (process.env.DATABASE || options.database);
        
            if (options.environment === 'production') {
                sqlite = require('sqlite3').cached;
        Severity: Minor
        Found in common/sqlite.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 getLimitQuery has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports.getLimitQuery = function(limitNumber) {
            if (typeof limitNumber !== 'undefined') {
                if (!isNaN(limitNumber)) {
                    let limit = parseInt(limitNumber, 10);
        
        
        Severity: Minor
        Found in common/databaseHelpers.js - About 25 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

        Severity
        Category
        Status
        Source
        Language