Mashape/alf-converter

View on GitHub

Showing 11 of 11 total issues

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

        if (entry.request.postData && entry.request.postData.text && entry.request.postData.text.length > 0) {
          let encoding = 'utf8'

          // should this be treted as base64 source?
          if (entry.request.postData.encoding && entry.request.postData.encoding === 'base64') {
Severity: Major
Found in src/converter.js and 1 other location - About 1 day to fix
src/converter.js on lines 67..82

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

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 (entry.response.content && entry.response.content.text && entry.response.content.text.length > 0) {
          let encoding = 'utf8'

          // should this be treted as base64 source?
          if (entry.response.content.encoding && entry.response.content.encoding === 'base64') {
Severity: Major
Found in src/converter.js and 1 other location - About 1 day to fix
src/converter.js on lines 44..59

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

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 1.0.0 has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    '1.0.0': (data, serviceToken) => {
      data.har.log.entries = data.har.log.entries.map((entry, index) => {
        if (data.clientIPAddress) {
          entry.clientIPAddress = data.clientIPAddress
        }
Severity: Minor
Found in src/converter.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 1.0.0 has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    '1.0.0': (data, serviceToken) => {
      data.har.log.entries = data.har.log.entries.map((entry, index) => {
        if (data.clientIPAddress) {
          entry.clientIPAddress = data.clientIPAddress
        }
Severity: Major
Found in src/converter.js - About 2 hrs to fix

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

            entry.request.bodyCaptured = Boolean(entry.request.postData && entry.request.postData.text && entry.request.postData.text.length > 0)
    Severity: Major
    Found in src/converter.js and 1 other location - About 1 hr to fix
    src/converter.js on lines 90..90

    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

            entry.response.bodyCaptured = Boolean(entry.response.content && entry.response.content.text && entry.response.content.text.length > 0)
    Severity: Major
    Found in src/converter.js and 1 other location - About 1 hr to fix
    src/converter.js on lines 89..89

    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

    Function detector has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function detector (data = {}) {
      return new Promise((resolve, reject) => {
        // ALF 2.0.0
        if (data.creator && data.entries && !data.har && !data.serviceToken && !data.har) {
          resolve({
    Severity: Minor
    Found in src/detector.js - About 1 hr to fix

      Function entries has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            data.har.log.entries = data.har.log.entries.map((entry, index) => {
              if (data.clientIPAddress) {
                entry.clientIPAddress = data.clientIPAddress
              }
      
      
      Severity: Minor
      Found in src/converter.js - About 1 hr to fix

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

            fs.writeFile(name, content, (err, data) => {
              if (err) {
                err.file = name
                return reject(err)
              }
        Severity: Minor
        Found in src/utils.js and 1 other location - About 50 mins to fix
        src/utils.js on lines 9..16

        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

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

            fs.readFile(name, (err, content) => {
              if (err) {
                err.file = name
                return reject(err)
              }
        Severity: Minor
        Found in src/utils.js and 1 other location - About 50 mins to fix
        src/utils.js on lines 22..29

        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

        Consider simplifying this complex logical expression.
        Open

            if (data.har && data.version && data.serviceToken && data.har && (data.har.log.entries[0].clientIPAddress || data.har.log.entries[0].request.bodyCaptured)) {
              resolve({
                data: data,
                format: 'ALF',
                version: '1.1.0'
        Severity: Major
        Found in src/detector.js - About 40 mins to fix
          Severity
          Category
          Status
          Source
          Language