inventid/iaas

View on GitHub

Showing 25 of 43 total issues

Function postgresql has 214 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function postgresql() {
  const configs = {
    user: config.get('postgresql.user'),
    database: config.get('postgresql.database'),
    password: config.get('postgresql.password'),
Severity: Major
Found in src/databases/postgresql.js - About 1 day to fix

    Function magic has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function magic(params, method, response, stats = undefined, metric = undefined, shouldBeFresh = false) {
      if (params === null) {
        // Invalid, hence reject
        response.status(400).end();
        if (metric) {
    Severity: Minor
    Found in src/imageResponse.js - About 6 hrs 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 magic has 104 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function magic(params, method, response, stats = undefined, metric = undefined, shouldBeFresh = false) {
      if (params === null) {
        // Invalid, hence reject
        response.status(400).end();
        if (metric) {
    Severity: Major
    Found in src/imageResponse.js - About 4 hrs to fix

      Function postgresql has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
      Open

      export default function postgresql() {
        const configs = {
          user: config.get('postgresql.user'),
          database: config.get('postgresql.database'),
          password: config.get('postgresql.password'),
      Severity: Minor
      Found in src/databases/postgresql.js - About 3 hrs 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 uploadImage has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const uploadImage = async (req, res) => {
        const sentToken = req.headers['x-token'];
        const name = req.params.name;
        log('info', `Requested image upload for image_id ${name} with token ${sentToken}`);
        const metric = timingMetric(UPLOAD, {fields: {name: name}});
      Severity: Major
      Found in src/index.js - About 2 hrs to fix

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

        import "babel-polyfill";
        
        import express from "express";
        import config from "config";
        import bodyParser from "body-parser";
        Severity: Minor
        Found in src/index.js - About 2 hrs to fix

          Function setup has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function setup() {
            const influxConnection = config.get("metrics.influx.dsn");
            const influx = new InfluxDB(influxConnection);
            log('debug', `Connecting influx to ${influxConnection}`);
          
          
          Severity: Minor
          Found in src/metrics/influx.js - About 1 hr to fix

            Function urlToParams has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export default function urlToParams(req, requireDimensions = true) {
              // The default settings
              const result = {
                name: null,
                width: undefined,
            Severity: Minor
            Found in src/urlParameters.js - About 1 hr to fix

              Function urlToParams has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
              Open

              export default function urlToParams(req, requireDimensions = true) {
                // The default settings
                const result = {
                  name: null,
                  width: undefined,
              Severity: Minor
              Found in src/urlParameters.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 writeOriented has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function writeOriented(source, destination, cropParameters) {
                // if possible, crop first (since the UA had that orientation), then orient
                if (cropParameters) {
                  const cropped = im(source).options(gmOptions)
                    .crop(cropParameters.width, cropParameters.height, cropParameters.xOffset, cropParameters.yOffset);
              Severity: Minor
              Found in src/image.js - About 1 hr to fix

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

                export default function integerCounter() {
                  let i = 0;
                
                  function incrementAndGet() {
                    i = i + 1;
                Severity: Minor
                Found in src/integerCounter.js - About 1 hr to fix

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

                  const uploadImage = async (req, res) => {
                    const sentToken = req.headers['x-token'];
                    const name = req.params.name;
                    log('info', `Requested image upload for image_id ${name} with token ${sentToken}`);
                    const metric = timingMetric(UPLOAD, {fields: {name: name}});
                  Severity: Minor
                  Found in src/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 deleteTokensWithoutAssociatedFile has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default async function deleteTokensWithoutAssociatedFile() {
                    // eslint-disable-next-line no-constant-condition
                    while (true) {
                      const toEnrich = await database.getTokensWithoutUploadedAt();
                  
                  
                  Severity: Minor
                  Found in src/migrations/deleteTokensWithoutAssociatedFile.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

                  Function populateUploadedAt has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export default async function populateUploadedAt() {
                    // eslint-disable-next-line no-constant-condition
                    while (true) {
                      const toEnrich = await database.getTokensWithoutUploadedAt();
                  
                  
                  Severity: Minor
                  Found in src/migrations/populateTokensUploadedAt.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

                  Function magic has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  export async function magic(params, method, response, stats = undefined, metric = undefined, shouldBeFresh = false) {
                  Severity: Minor
                  Found in src/imageResponse.js - About 45 mins to fix

                    Function calculateNewBounds has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const calculateNewBounds = async (params) => {
                      // Resize the parameters
                      // If no params are set then we load them from the actual image before calculating new bounds
                      if (!params.width || !params.height) {
                        const fileSize = await image.imageSize(imagePath(params.name));
                    Severity: Minor
                    Found in src/imageResponse.js - About 45 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;
                    Severity: Major
                    Found in src/index.js - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                          return cover(client, params);
                      Severity: Major
                      Found in src/image.js - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                              return;
                        Severity: Major
                        Found in src/imageResponse.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                return;
                          Severity: Major
                          Found in src/imageResponse.js - About 30 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language