haraka/email-message

View on GitHub
index.js

Summary

Maintainability
F
3 days
Test Coverage

Consider simplifying this complex logical expression.
Open

      if (
        (buf[i + 2] === 98 || buf[i + 2] === 66) && // "b" or "B"
        (buf[i + 3] === 111 || buf[i + 3] === 79) && // "o" or "O"
        (buf[i + 4] === 100 || buf[i + 4] === 68) && // "d" or "D"
        (buf[i + 5] === 121 || buf[i + 5] === 89) && // "y" or "Y"
Severity: Critical
Found in index.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

          if (
            (buf[i + 2] === 104 || buf[i + 2] === 72) && // "h" or "H"
            (buf[i + 3] === 116 || buf[i + 3] === 84) && // "t" or "T"
            (buf[i + 4] === 109 || buf[i + 4] === 77) && // "m" or "M"
            (buf[i + 5] === 108 || buf[i + 5] === 76) && // "l" or "L"
    Severity: Critical
    Found in index.js - About 1 hr to fix

      Function _decode_header has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      function _decode_header(matched, encoding, lang, cte, data) {
      Severity: Minor
      Found in index.js - About 35 mins to fix

        Function insert_banner has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        function insert_banner(ct, enc, buf, cd, banners) {
        Severity: Minor
        Found in index.js - About 35 mins to fix

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

                if (
                  (buf[i + 2] === 98 || buf[i + 2] === 66) && // "b" or "B"
                  (buf[i + 3] === 111 || buf[i + 3] === 79) && // "o" or "O"
                  (buf[i + 4] === 100 || buf[i + 4] === 68) && // "d" or "D"
                  (buf[i + 5] === 121 || buf[i + 5] === 89) && // "y" or "Y"
          Severity: Major
          Found in index.js and 1 other location - About 5 hrs to fix
          index.js on lines 761..770

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

          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

                if (
                  (buf[i + 2] === 104 || buf[i + 2] === 72) && // "h" or "H"
                  (buf[i + 3] === 116 || buf[i + 3] === 84) && // "t" or "T"
                  (buf[i + 4] === 109 || buf[i + 4] === 77) && // "m" or "M"
                  (buf[i + 5] === 108 || buf[i + 5] === 76) && // "l" or "L"
          Severity: Major
          Found in index.js and 1 other location - About 5 hrs to fix
          index.js on lines 751..760

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

          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

            add_end(key, value) {
              if (!key) key = 'X-Haraka-Blank';
              value = value.replace(/(\r?\n)*$/, '');
              if (/[^\x00-\x7f]/.test(value)) {
                value = libmime.encodeWords(value, 'Q');
          Severity: Major
          Found in index.js and 1 other location - About 5 hrs to fix
          index.js on lines 142..151

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

          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

            add(key, value) {
              if (!key) key = 'X-Haraka-Blank';
              value = value.replace(/(\r?\n)*$/, '');
              if (/[^\x00-\x7f]/.test(value)) {
                value = libmime.encodeWords(value, 'Q');
          Severity: Major
          Found in index.js and 1 other location - About 5 hrs to fix
          index.js on lines 165..174

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

          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

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

              if (this.encoding) {
                this.emit('data', data.toString(this.encoding));
              } else {
                this.emit('data', data);
              }
          Severity: Minor
          Found in index.js and 1 other location - About 50 mins to fix
          index.js on lines 874..878

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

          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

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

                    if (this.encoding) {
                      this.emit('data', data.toString(this.encoding));
                    } else {
                      this.emit('data', data);
                    }
          Severity: Minor
          Found in index.js and 1 other location - About 50 mins to fix
          index.js on lines 855..859

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

          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

          There are no issues that match your filters.

          Category
          Status