pat310/google-trends-api

View on GitHub

Showing 7 of 51 total issues

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

        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

          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

            Function constructInterestObj has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export function constructInterestObj(obj, cbFunc) {
            
              if (typeof obj === 'function') cbFunc = obj;
            
              obj = validateObj(obj, cbFunc);
            Severity: Minor
            Found in src/utilities.js - About 25 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

            Severity
            Category
            Status
            Source
            Language