pat310/google-trends-api

View on GitHub

Showing 51 of 51 total issues

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

    it('should eventually return', (done) => {
      const resultsFunc = getTrendingResults(request);
      const { obj } = constructTrendingObj({geo: 'US'});

      resultsFunc('Daily trends', obj)
Severity: Major
Found in test/utilities.spec.js and 1 other location - About 6 hrs to fix
test/utilities.spec.js on lines 297..311

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

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 eventually return', (done) => {
      const resultsFunc = getInterestResults(request);
      const { obj } = constructInterestObj({keyword: 'Brooklyn'});

      resultsFunc('Interest over time', obj)
Severity: Major
Found in test/utilities.spec.js and 1 other location - About 6 hrs to fix
test/utilities.spec.js on lines 467..481

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

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

File utilities.spec.js has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';
import chai from 'chai';
import {
  constructInterestObj,
  constructTrendingObj,
Severity: Minor
Found in test/utilities.spec.js - About 6 hrs to fix

    Function getInterestResults has 82 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function getInterestResults(request) {
      return (searchType, obj) => {
        const map = {
          'Auto complete': {
            path: `/trends/api/autocomplete/${encodeURIComponent(obj.keyword)}`,
    Severity: Major
    Found in src/utilities.js - About 3 hrs to fix

      File utilities.js has 287 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      export function isLessThan7Days(date1, date2) {
        return (Math.abs(date2 - date1) / (24 * 60 * 60 * 1000)) < 7;
      }
      
      
      Severity: Minor
      Found in src/utilities.js - About 2 hrs to fix

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

              resultsFunc('Daily trends', obj)
              .then((res) => {
                expect(res).to.exist;
                expect(res).to.equal(expectedFailureMsg);
                done();
        Severity: Major
        Found in test/utilities.spec.js and 1 other location - About 2 hrs to fix
        test/utilities.spec.js on lines 375..383

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

        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

              resultsFunc('Interest over time', obj)
              .then((res) => {
                expect(res).to.exist;
                expect(res).to.equal(expectedFailureMsg);
                done();
        Severity: Major
        Found in test/utilities.spec.js and 1 other location - About 2 hrs to fix
        test/utilities.spec.js on lines 497..505

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

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

        export function getTrendingResults(request) {
          return (searchType, obj) => {
            const searchTypeMap = {
              'Daily trends': {
                path: '/trends/api/dailytrends',
        Severity: Minor
        Found in src/utilities.js - About 1 hr to fix

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

              it('should default trendDate to today if not provided', () => {
                expect(
                  convertDateToString(constructTrendingObj(
                    {geo: 'US', trendDate: '2018-12-25'}).obj.trendDate)).to.equal(
                    convertDateToString(new Date()));
          Severity: Major
          Found in test/utilities.spec.js and 1 other location - About 1 hr to fix
          test/utilities.spec.js on lines 443..448

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

          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 default trendDate to today provided in wrong format', () => {
                expect(
                  convertDateToString(
                    constructTrendingObj({geo: 'US', trendDate: '2018-12-25'})
                    .obj.trendDate)).to.equal(convertDateToString(new Date()));
          Severity: Major
          Found in test/utilities.spec.js and 1 other location - About 1 hr to fix
          test/utilities.spec.js on lines 436..441

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

          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

              it('should return an error if keyword and geo length are not equal', () => {
                expect(constructInterestObj({
                  keyword: ['foo', 'bar'],
                  geo: ['Brooklyn', 'DC', 'Boston'],
                }).obj).to.be.an('error');
          Severity: Major
          Found in test/utilities.spec.js and 1 other location - About 1 hr to fix
          test/utilities.spec.js on lines 203..208

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

          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

              it('should return an error if keyword and geo length are not equal', () => {
                expect(constructInterestObj({
                  keyword: ['foo', 'bar'],
                  geo: ['Brooklyn', 'DC', 'Boston'],
                }).obj).to.be.an('error');
          Severity: Major
          Found in test/utilities.spec.js and 1 other location - About 1 hr to fix
          test/utilities.spec.js on lines 182..187

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

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

          export function constructTrendingObj(obj, cbFunc) {
            if (typeof obj === 'function') cbFunc = obj;
          
            if (!obj || !!obj && typeof obj !== 'object' || Array.isArray(obj)) {
              obj = new Error('Must supply an object');
          Severity: Minor
          Found in src/utilities.js - About 1 hr to fix

            Function constructTrendingObj has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            export function constructTrendingObj(obj, cbFunc) {
              if (typeof obj === 'function') cbFunc = obj;
            
              if (!obj || !!obj && typeof obj !== 'object' || Array.isArray(obj)) {
                obj = new Error('Must supply an object');
            Severity: Minor
            Found in src/utilities.js - About 1 hr 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 7 locations. Consider refactoring.
            Open

                it('dailyTrends', () => {
                  expect(google.dailyTrends).to.exist;
                  expect(google.dailyTrends).to.be.a('function');
                });
            Severity: Major
            Found in test/index.spec.js and 6 other locations - About 1 hr to fix
            test/index.spec.js on lines 9..12
            test/index.spec.js on lines 14..17
            test/index.spec.js on lines 19..22
            test/index.spec.js on lines 24..27
            test/index.spec.js on lines 29..32
            test/index.spec.js on lines 34..37

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

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

                it('realTimeTrends', () => {
                  expect(google.realTimeTrends).to.exist;
                  expect(google.realTimeTrends).to.be.a('function');
                });
            Severity: Major
            Found in test/index.spec.js and 6 other locations - About 1 hr to fix
            test/index.spec.js on lines 9..12
            test/index.spec.js on lines 14..17
            test/index.spec.js on lines 19..22
            test/index.spec.js on lines 24..27
            test/index.spec.js on lines 29..32
            test/index.spec.js on lines 39..42

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

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

                it('interestByRegion', () => {
                  expect(google.interestByRegion).to.exist;
                  expect(google.interestByRegion).to.be.a('function');
                });
            Severity: Major
            Found in test/index.spec.js and 6 other locations - About 1 hr to fix
            test/index.spec.js on lines 9..12
            test/index.spec.js on lines 19..22
            test/index.spec.js on lines 24..27
            test/index.spec.js on lines 29..32
            test/index.spec.js on lines 34..37
            test/index.spec.js on lines 39..42

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

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

                it('relatedQueries', () => {
                  expect(google.relatedQueries).to.exist;
                  expect(google.relatedQueries).to.be.a('function');
                });
            Severity: Major
            Found in test/index.spec.js and 6 other locations - About 1 hr to fix
            test/index.spec.js on lines 9..12
            test/index.spec.js on lines 14..17
            test/index.spec.js on lines 19..22
            test/index.spec.js on lines 29..32
            test/index.spec.js on lines 34..37
            test/index.spec.js on lines 39..42

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

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

                it('relatedTopics', () => {
                  expect(google.relatedTopics).to.exist;
                  expect(google.relatedTopics).to.be.a('function');
                });
            Severity: Major
            Found in test/index.spec.js and 6 other locations - About 1 hr to fix
            test/index.spec.js on lines 9..12
            test/index.spec.js on lines 14..17
            test/index.spec.js on lines 19..22
            test/index.spec.js on lines 24..27
            test/index.spec.js on lines 34..37
            test/index.spec.js on lines 39..42

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

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

                it('interestOverTime', () => {
                  expect(google.interestOverTime).to.exist;
                  expect(google.interestOverTime).to.be.a('function');
                });
            Severity: Major
            Found in test/index.spec.js and 6 other locations - About 1 hr to fix
            test/index.spec.js on lines 9..12
            test/index.spec.js on lines 14..17
            test/index.spec.js on lines 24..27
            test/index.spec.js on lines 29..32
            test/index.spec.js on lines 34..37
            test/index.spec.js on lines 39..42

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

            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