inventid/opengraph-cacher

View on GitHub

Showing 20 of 23 total issues

Function fetchFromRemote has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

async function fetchFromRemote(urlToFetch) {
    const options = {
        url : encodeURI(urlToFetch),
        timeout : HTTP_TIMEOUT,
        headers : {
Severity: Minor
Found in src/opengraph.js - About 2 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 fetchFromRemote has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

async function fetchFromRemote(urlToFetch) {
    const options = {
        url : encodeURI(urlToFetch),
        timeout : HTTP_TIMEOUT,
        headers : {
Severity: Minor
Found in src/opengraph.js - About 1 hr to fix

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

            it('should prefer the set url', async () => {
                const result = await postProcess("http://bit.ly/redirect", {ogUrl : 'http://example.com'});
                assert.strictEqual(result.data.url[0].value, 'http://example.com');
            });
    Severity: Major
    Found in test/mapper.js and 1 other location - About 1 hr to fix
    test/mapper.js on lines 17..20

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

    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

            it('should set the name if given', async () => {
                const result = await postProcess("http://bit.ly/redirect", {ogSiteName : 'Example'});
                assert.strictEqual(result.data.site_name[0].value, 'Example');
            });
    Severity: Major
    Found in test/mapper.js and 1 other location - About 1 hr to fix
    test/mapper.js on lines 7..10

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

    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 postProcess has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function postProcess(url, data) {
        const result = defaultOutput(url);
        const canonicalUrl = data.ogUrl || url;
    
        // Format images for their special cases
    Severity: Minor
    Found in src/mapper.js - About 1 hr to fix

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

      app.delete('/opengraph', async (req, res) => {
          const data = await removeOpengraphData(req.query.url);
          respondWithData(res, data);
      });
      Severity: Minor
      Found in src/index.js and 1 other location - About 40 mins to fix
      src/index.js on lines 19..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 48.

      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

      app.get('/opengraph', async (req, res) => {
          const data = await getOpengraphData(req.query.url);
          respondWithData(res, data);
      });
      Severity: Minor
      Found in src/index.js and 1 other location - About 40 mins to fix
      src/index.js on lines 23..26

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

      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

      Parsing error: Invalid ecmaVersion.
      Open

      import {describe, it} from 'mocha';
      Severity: Minor
      Found in test/mapper.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import {promisify} from 'es6-promisify';
      Severity: Minor
      Found in src/network.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import express from 'express';
      Severity: Minor
      Found in src/index.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      // A top 1000 over Alexa at one point in time (limited to approx 150 entries)
      Severity: Minor
      Found in test/knownDomainList.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import {describe, it} from 'mocha';
      Severity: Minor
      Found in test/opengraph.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import defaultOutput from './defaultOutput';
      Severity: Minor
      Found in src/mapper.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import moment from "moment-timezone";
      Severity: Minor
      Found in src/log.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import ogs from 'open-graph-scraper';
      Severity: Minor
      Found in src/opengraph.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import {describe, it} from 'mocha';
      Severity: Minor
      Found in test/network.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      const moment = require("moment-timezone");
      Severity: Minor
      Found in src/defaultOutput.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import './mapper';
      Severity: Minor
      Found in test/index.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import {it} from "mocha";
      Severity: Minor
      Found in test/knownDomains.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Parsing error: Invalid ecmaVersion.
      Open

      import ElasticSearch from 'elasticsearch';
      Severity: Minor
      Found in src/cache.js by eslint

      For more information visit Source: http://eslint.org/docs/rules/

      Severity
      Category
      Status
      Source
      Language