zephinzer/annams

View on GitHub

Showing 7 of 39 total issues

Function KnexMock has 50 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function KnexMock(...args) {
  const createSpies = KnexMock.createSpies.bind(this);
  this.databaseName = args[0];
  KnexMock.functions.forEach((mockedFunctionKey) => {
    createSpies(mockedFunctionKey);
Severity: Minor
Found in test/mocks/knex.js - About 2 hrs to fix

    Function createMiddleware has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    readinessRouteHandler.createMiddleware = (readiness) => (
      async (req, res) => {
        const status = await readiness.getStatus();
        (!status) && console.error(readiness.error);
        const alerts = Object.keys(readiness.warning).reduce((prev, curr) => {
    Severity: Minor
    Found in src/server/readiness/index.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 KnexMockSchema has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function KnexMockSchema(knexMock) {
      this.knex = knexMock;
    
      this.spy = {
        alterTable: sinon.spy(),
    Severity: Minor
    Found in test/mocks/knex.schema.js - About 1 hr to fix

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

      function postAccount(req, res, next) {
        if (!utility.validate.requestHasBody(req)) {
          error.trigger.badRequest();
        }
      
      
      Severity: Minor
      Found in src/server/api/v1/account/post.js - About 1 hr to fix

        Function postAccount has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function postAccount(req, res, next) {
          if (!utility.validate.requestHasBody(req)) {
            error.trigger.badRequest();
          }
        
        
        Severity: Minor
        Found in src/server/api/v1/account/post.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 serverErrorHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function serverErrorHandler(err, req, res, next) {
          if (err && typeof err.stack !== 'undefined') {
            console.error(req.id, '|', err.stack);
          }
          const status = (err && typeof err.status === 'number')
        Severity: Minor
        Found in src/server/error/index.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 createAccount has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        function createAccount(
          db,
          {
            email = null,
            username = null,
        Severity: Minor
        Found in src/account/create.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