tollmanz/csp-report-norm

View on GitHub

Showing 21 of 21 total issues

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

function extract(payload) {
  var sourceFile = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('source-file')) {
    sourceFile = payload['csp-report']['source-file'];
Severity: Major
Found in lib/extract/sourceFile.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var documentURI = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('document-uri')) {
    documentURI = payload['csp-report']['document-uri'];
Severity: Major
Found in lib/extract/documentURI.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var violatedDirective = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('violated-directive')) {
    violatedDirective = payload['csp-report']['violated-directive'];
Severity: Major
Found in lib/extract/violatedDirective.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var effectiveDirective = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('effective-directive')) {
    effectiveDirective = payload['csp-report']['effective-directive'];
Severity: Major
Found in lib/extract/effectiveDirective.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var columnNumber = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('column-number')) {
    columnNumber = payload['csp-report']['column-number'];
Severity: Major
Found in lib/extract/columnNumber.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var blockedURI = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('blocked-uri')) {
    blockedURI = payload['csp-report']['blocked-uri'];
Severity: Major
Found in lib/extract/blockedURI.js and 9 other locations - About 1 hr to fix
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var referrer = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('referrer')) {
    referrer = payload['csp-report']['referrer'];
Severity: Major
Found in lib/extract/referrer.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var originalDirective = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('original-policy')) {
    originalDirective = payload['csp-report']['original-policy'];
Severity: Major
Found in lib/extract/originalPolicy.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var lineNumber = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('line-number')) {
    lineNumber = payload['csp-report']['line-number'];
Severity: Major
Found in lib/extract/lineNumber.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/statusCode.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 10 locations. Consider refactoring.
Open

function extract(payload) {
  var referrer = '';

  if (payload.hasOwnProperty('csp-report') && payload['csp-report'].hasOwnProperty('status-code')) {
    referrer = payload['csp-report']['status-code'];
Severity: Major
Found in lib/extract/statusCode.js and 9 other locations - About 1 hr to fix
lib/extract/blockedURI.js on lines 9..17
lib/extract/columnNumber.js on lines 9..17
lib/extract/documentURI.js on lines 9..17
lib/extract/effectiveDirective.js on lines 9..17
lib/extract/lineNumber.js on lines 9..17
lib/extract/originalPolicy.js on lines 9..17
lib/extract/referrer.js on lines 13..21
lib/extract/sourceFile.js on lines 9..17
lib/extract/violatedDirective.js on lines 9..17

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 67.

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 2 locations. Consider refactoring.
Open

function get(payload, headers) {
  var candidateBlockedURI = extractBlockedURI(payload);

  // The protected resource is the resource that the CSP is applied to. This can be a lot of things, but typically will
  // refer to the main HTML for a webpage. Here, the assumption is made that the protected resource is the request
Severity: Major
Found in lib/get/blockedURI.js and 1 other location - About 1 hr to fix
lib/get/sourceFile.js on lines 13..22

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 64.

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 2 locations. Consider refactoring.
Open

function get(payload, headers) {
  var candidateSourceFile = extractSourceFile(payload);

  // The protected resource is the resource that the CSP is applied to. This can be a lot of things, but typically will
  // refer to the main HTML for a webpage. Here, the assumption is made that the protected resource is the request
Severity: Major
Found in lib/get/sourceFile.js and 1 other location - About 1 hr to fix
lib/get/blockedURI.js on lines 13..22

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 64.

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

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

function isSpecialCase(blockedURI) {
  var result = false;
  var specialCases = [
    'about',
    'about:blank',
Severity: Minor
Found in lib/sanitize/blockedURI.js - About 1 hr to fix

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

    function get(payload) {
      var candidateViolatedDirective = extractViolatedDirective(payload);
    
      // Directive not found. Attempt to get it from the root of the payload.
      if (candidateViolatedDirective === '') {
    Severity: Major
    Found in lib/get/violatedDirective.js and 1 other location - About 1 hr to fix
    lib/get/documentURI.js on lines 19..28

    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 55.

    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 2 locations. Consider refactoring.
    Open

    function get(payload) {
      var candidateDocumentURI = extractDocumentURI(payload);
    
      // Directive not found. Attempt to get it from the root of the payload.
      if (candidateDocumentURI === '') {
    Severity: Major
    Found in lib/get/documentURI.js and 1 other location - About 1 hr to fix
    lib/get/violatedDirective.js on lines 13..22

    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 55.

    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

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

    function sanitize(blockedURI, protectedResource) {
      var result = '';
      var blockedURIPieces = {};
      var protectedResourcePieces = {};
    
    
    Severity: Minor
    Found in lib/sanitize/blockedURI.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

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

    var sanitize = function (lineNumber) {
      var result = -1;
    
      if (isNumeric(lineNumber)) {
        result = parseInt(lineNumber, 10);
    Severity: Minor
    Found in lib/sanitize/lineNumber.js and 1 other location - About 45 mins to fix
    lib/sanitize/columnNumber.js on lines 11..19

    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 50.

    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

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

    function sanitize(sourceFile, protectedResource) {
      var result = '';
      var sourceFilePieces = {};
      var protectedResourcePieces = {};
    
    
    Severity: Minor
    Found in lib/sanitize/sourceFile.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

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

    var sanitize = function (columnNumber) {
      var result = -1;
    
      if (isNumeric(columnNumber)) {
        result = parseInt(columnNumber, 10);
    Severity: Minor
    Found in lib/sanitize/columnNumber.js and 1 other location - About 45 mins to fix
    lib/sanitize/lineNumber.js on lines 11..19

    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 50.

    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 2 locations. Consider refactoring.
    Open

    function extract(payload) {
      var violatedDirective = '';
    
      if (payload.hasOwnProperty('violated-directive')) {
        violatedDirective = payload['violated-directive'];
    Severity: Minor
    Found in lib/extract/violatedDirectiveRoot.js and 1 other location - About 35 mins to fix
    lib/extract/documentURL.js on lines 9..17

    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 47.

    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

    Severity
    Category
    Status
    Source
    Language