UnlyEd/utils-aws

View on GitHub

Showing 6 of 6 total issues

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  test('should return a success status code 200', () => {
    const res = success({ success: true });
    expect(res.statusCode).toEqual(200);
    expect(JSON.parse(res.body).success).toEqual(true);
  });
Severity: Major
Found in src/APIResponse.test.js and 2 other locations - About 2 hrs to fix
src/APIResponse.test.js on lines 14..18
src/APIResponse.test.js on lines 26..30

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  test('should return a failure status code 500', () => {
    const res = failure({ success: false });
    expect(res.statusCode).toEqual(500);
    expect(JSON.parse(res.body).success).toEqual(false);
  });
Severity: Major
Found in src/APIResponse.test.js and 2 other locations - About 2 hrs to fix
src/APIResponse.test.js on lines 8..12
src/APIResponse.test.js on lines 26..30

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

  test('should return a success status code 200', () => {
    const res = unauthorized({ forbidden: true });
    expect(res.statusCode).toEqual(403);
    expect(JSON.parse(res.body).forbidden).toEqual(true);
  });
Severity: Major
Found in src/APIResponse.test.js and 2 other locations - About 2 hrs to fix
src/APIResponse.test.js on lines 8..12
src/APIResponse.test.js on lines 14..18

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 80.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid too many return statements within this function.
Open

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

    Unexpected newline after '('.
    Open

        expect(getHeadersUsefulData(headers[0])).toEqual(
    Severity: Minor
    Found in src/headers.test.js by eslint

    enforce consistent line breaks inside function parentheses (function-paren-newline)

    Many style guides require or disallow newlines inside of function parentheses.

    Rule Details

    This rule enforces consistent line breaks inside parentheses of function parameters or arguments.

    Options

    This rule has a single option, which can either be a string or an object.

    • "always" requires line breaks inside all function parentheses.
    • "never" disallows line breaks inside all function parentheses.
    • "multiline" (default) requires linebreaks inside function parentheses if any of the parameters/arguments have a line break between them. Otherwise, it disallows linebreaks.
    • "consistent" requires consistent usage of linebreaks for each pair of parentheses. It reports an error if one parenthesis in the pair has a linebreak inside it and the other parenthesis does not.
    • { "minItems": value } requires linebreaks inside function parentheses if the number of parameters/arguments is at least value. Otherwise, it disallows linebreaks.

    Example configurations:

    {
      "rules": {
        "function-paren-newline": ["error", "never"]
      }
    }
    {
      "rules": {
        "function-paren-newline": ["error", { "minItems": 3 }]
      }
    }

    Examples of incorrect code for this rule with the "always" option:

    /* eslint function-paren-newline: ["error", "always"] */
    
    function foo(bar, baz) {}
    
    var foo = function(bar, baz) {};
    
    var foo = (bar, baz) => {};
    
    foo(bar, baz);

    Examples of correct code for this rule with the "always" option:

    /* eslint function-paren-newline: ["error", "always"] */
    
    function foo(
      bar,
      baz
    ) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (
      bar,
      baz
    ) => {};
    
    foo(
      bar,
      baz
    );

    Examples of incorrect code for this rule with the "never" option:

    /* eslint function-paren-newline: ["error", "never"] */
    
    function foo(
      bar,
      baz
    ) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (
      bar,
      baz
    ) => {};
    
    foo(
      bar,
      baz
    );

    Examples of correct code for this rule with the "never" option:

    /* eslint function-paren-newline: ["error", "never"] */
    
    function foo(bar, baz) {}
    
    function foo(bar,
                 baz) {}
    
    var foo = function(bar, baz) {};
    
    var foo = (bar, baz) => {};
    
    foo(bar, baz);
    
    foo(bar,
      baz);

    Examples of incorrect code for this rule with the default "multiline" option:

    /* eslint function-paren-newline: ["error", "multiline"] */
    
    function foo(bar,
      baz
    ) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (
      bar,
      baz) => {};
    
    foo(bar,
      baz);
    
    foo(
      function() {
        return baz;
      }
    );

    Examples of correct code for this rule with the default "multiline" option:

    /* eslint function-paren-newline: ["error", "multiline"] */
    
    function foo(bar, baz) {}
    
    var foo = function(
      bar,
      baz
    ) {};
    
    var foo = (bar, baz) => {};
    
    foo(bar, baz, qux);
    
    foo(
      bar,
      baz,
      qux
    );
    
    foo(function() {
      return baz;
    });

    Examples of incorrect code for this rule with the "consistent" option:

    /* eslint function-paren-newline: ["error", "consistent"] */
    
    function foo(bar,
      baz
    ) {}
    
    var foo = function(bar,
      baz
    ) {};
    
    var foo = (
      bar,
      baz) => {};
    
    foo(
      bar,
      baz);
    
    foo(
      function() {
        return baz;
      });

    Examples of correct code for this rule with the consistent "consistent" option:

    /* eslint function-paren-newline: ["error", "consistent"] */
    
    function foo(bar,
      baz) {}
    
    var foo = function(bar, baz) {};
    
    var foo = (
      bar,
      baz
    ) => {};
    
    foo(
      bar, baz
    );
    
    foo(
      function() {
        return baz;
      }
    );

    Examples of incorrect code for this rule with the { "minItems": 3 } option:

    /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
    
    function foo(
      bar,
      baz
    ) {}
    
    function foo(bar, baz, qux) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (bar,
      baz) => {};
    
    foo(bar,
      baz);

    Examples of correct code for this rule with the { "minItems": 3 } option:

    /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
    
    function foo(bar, baz) {}
    
    var foo = function(
      bar,
      baz,
      qux
    ) {};
    
    var foo = (
      bar, baz, qux
    ) => {};
    
    foo(bar, baz);
    
    foo(
      bar, baz, qux
    );

    When Not To Use It

    If don't want to enforce consistent linebreaks inside function parentheses, do not turn on this rule. Source: http://eslint.org/docs/rules/

    Unexpected newline before ')'.
    Open

        );
    Severity: Minor
    Found in src/headers.test.js by eslint

    enforce consistent line breaks inside function parentheses (function-paren-newline)

    Many style guides require or disallow newlines inside of function parentheses.

    Rule Details

    This rule enforces consistent line breaks inside parentheses of function parameters or arguments.

    Options

    This rule has a single option, which can either be a string or an object.

    • "always" requires line breaks inside all function parentheses.
    • "never" disallows line breaks inside all function parentheses.
    • "multiline" (default) requires linebreaks inside function parentheses if any of the parameters/arguments have a line break between them. Otherwise, it disallows linebreaks.
    • "consistent" requires consistent usage of linebreaks for each pair of parentheses. It reports an error if one parenthesis in the pair has a linebreak inside it and the other parenthesis does not.
    • { "minItems": value } requires linebreaks inside function parentheses if the number of parameters/arguments is at least value. Otherwise, it disallows linebreaks.

    Example configurations:

    {
      "rules": {
        "function-paren-newline": ["error", "never"]
      }
    }
    {
      "rules": {
        "function-paren-newline": ["error", { "minItems": 3 }]
      }
    }

    Examples of incorrect code for this rule with the "always" option:

    /* eslint function-paren-newline: ["error", "always"] */
    
    function foo(bar, baz) {}
    
    var foo = function(bar, baz) {};
    
    var foo = (bar, baz) => {};
    
    foo(bar, baz);

    Examples of correct code for this rule with the "always" option:

    /* eslint function-paren-newline: ["error", "always"] */
    
    function foo(
      bar,
      baz
    ) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (
      bar,
      baz
    ) => {};
    
    foo(
      bar,
      baz
    );

    Examples of incorrect code for this rule with the "never" option:

    /* eslint function-paren-newline: ["error", "never"] */
    
    function foo(
      bar,
      baz
    ) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (
      bar,
      baz
    ) => {};
    
    foo(
      bar,
      baz
    );

    Examples of correct code for this rule with the "never" option:

    /* eslint function-paren-newline: ["error", "never"] */
    
    function foo(bar, baz) {}
    
    function foo(bar,
                 baz) {}
    
    var foo = function(bar, baz) {};
    
    var foo = (bar, baz) => {};
    
    foo(bar, baz);
    
    foo(bar,
      baz);

    Examples of incorrect code for this rule with the default "multiline" option:

    /* eslint function-paren-newline: ["error", "multiline"] */
    
    function foo(bar,
      baz
    ) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (
      bar,
      baz) => {};
    
    foo(bar,
      baz);
    
    foo(
      function() {
        return baz;
      }
    );

    Examples of correct code for this rule with the default "multiline" option:

    /* eslint function-paren-newline: ["error", "multiline"] */
    
    function foo(bar, baz) {}
    
    var foo = function(
      bar,
      baz
    ) {};
    
    var foo = (bar, baz) => {};
    
    foo(bar, baz, qux);
    
    foo(
      bar,
      baz,
      qux
    );
    
    foo(function() {
      return baz;
    });

    Examples of incorrect code for this rule with the "consistent" option:

    /* eslint function-paren-newline: ["error", "consistent"] */
    
    function foo(bar,
      baz
    ) {}
    
    var foo = function(bar,
      baz
    ) {};
    
    var foo = (
      bar,
      baz) => {};
    
    foo(
      bar,
      baz);
    
    foo(
      function() {
        return baz;
      });

    Examples of correct code for this rule with the consistent "consistent" option:

    /* eslint function-paren-newline: ["error", "consistent"] */
    
    function foo(bar,
      baz) {}
    
    var foo = function(bar, baz) {};
    
    var foo = (
      bar,
      baz
    ) => {};
    
    foo(
      bar, baz
    );
    
    foo(
      function() {
        return baz;
      }
    );

    Examples of incorrect code for this rule with the { "minItems": 3 } option:

    /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
    
    function foo(
      bar,
      baz
    ) {}
    
    function foo(bar, baz, qux) {}
    
    var foo = function(
      bar, baz
    ) {};
    
    var foo = (bar,
      baz) => {};
    
    foo(bar,
      baz);

    Examples of correct code for this rule with the { "minItems": 3 } option:

    /* eslint function-paren-newline: ["error", { "minItems": 3 }] */
    
    function foo(bar, baz) {}
    
    var foo = function(
      bar,
      baz,
      qux
    ) {};
    
    var foo = (
      bar, baz, qux
    ) => {};
    
    foo(bar, baz);
    
    foo(
      bar, baz, qux
    );

    When Not To Use It

    If don't want to enforce consistent linebreaks inside function parentheses, do not turn on this rule. Source: http://eslint.org/docs/rules/

    Severity
    Category
    Status
    Source
    Language