dataplug-io/hubspot-dataplug

View on GitHub

Showing 18 of 18 total issues

File contacts.js has 448 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const _ = require('lodash')
const { URL } = require('url')
const moment = require('moment')
const { Source, Mapper } = require('@dataplug/dataplug')
const { HttpGetReader, PagedHttpGetReader } = require('@dataplug/dataplug-http')
Severity: Minor
Found in lib/collections/contacts.js - About 6 hrs to fix

    Function factory has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

    const factory = (params) => {
      params = _.clone(params)
    
      let uri = '/contacts/v1/lists/all/contacts/all'
      if (params.recently === 'created') {
    Severity: Minor
    Found in lib/collections/contacts.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

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

        property: {
          type: 'object',
          properties: {
            value: {
              type: 'string'
    Severity: Major
    Found in lib/collections/deals.js and 1 other location - About 2 hrs to fix
    lib/collections/companies.js on lines 16..39

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

    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

        property: {
          type: 'object',
          properties: {
            value: {
              type: 'string'
    Severity: Major
    Found in lib/collections/companies.js and 1 other location - About 2 hrs to fix
    lib/collections/deals.js on lines 40..63

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

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

    const factory = (params) => {
      params = _.clone(params)
    
      let uri = '/contacts/v1/lists/all/contacts/all'
      if (params.recently === 'created') {
    Severity: Major
    Found in lib/collections/contacts.js - About 2 hrs to fix

      Function factory has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const factory = (params) => {
        params = _.clone(params)
      
        let uri = '/companies/v2/companies/paged'
        let selector = '!.companies.*'
      Severity: Major
      Found in lib/collections/companies.js - About 2 hrs to fix

        Function factory has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const factory = (params) => {
          params = _.clone(params)
        
          let uri = '/deals/v1/deal/paged'
          let selector = '!.deals.*'
        Severity: Major
        Found in lib/collections/deals.js - About 2 hrs to fix

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

            if (params.recently) {
              const since = moment(params.since)
              if (since.diff(earliestSince) < 0) {
                throw new Error(`Invalid range: since ${since} can not be before ${earliestSince}`)
              }
          Severity: Major
          Found in lib/collections/companies.js and 1 other location - About 2 hrs to fix
          lib/collections/deals.js on lines 194..201

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

          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 (params.recently) {
              const since = moment(params.since)
              if (since.diff(earliestSince) < 0) {
                throw new Error(`Invalid range: since ${since} can not be before ${earliestSince}`)
              }
          Severity: Major
          Found in lib/collections/deals.js and 1 other location - About 2 hrs to fix
          lib/collections/companies.js on lines 157..164

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

          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

            const nextPage = (page, data) => {
              if (data && data['has-more']) {
                const offset = data['offset']
                page.query['offset'] = offset
          
          
          Severity: Major
          Found in lib/collections/companies.js and 1 other location - About 1 hr to fix
          lib/collections/deals.js on lines 204..212

          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

            const nextPage = (page, data) => {
              if (data && data['hasMore']) {
                const offset = data['offset']
                page.query['offset'] = offset
          
          
          Severity: Major
          Found in lib/collections/deals.js and 1 other location - About 1 hr to fix
          lib/collections/companies.js on lines 167..175

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

          const factory = (params) => {
            params = _.clone(params)
          
            let uri = '/companies/v2/companies/paged'
            let selector = '!.companies.*'
          Severity: Minor
          Found in lib/collections/companies.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 factory has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          const factory = (params) => {
            params = _.clone(params)
          
            let uri = '/deals/v1/deal/paged'
            let selector = '!.deals.*'
          Severity: Minor
          Found in lib/collections/deals.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 2 locations. Consider refactoring.
          Open

            if (params.recently === 'created') {
              uri = '/deals/v1/deal/recent/created'
              selector = '!.results.*'
            } else if (params.recently === 'updated') {
              uri = '/deals/v1/deal/recent/modified'
          Severity: Major
          Found in lib/collections/deals.js and 1 other location - About 1 hr to fix
          lib/collections/companies.js on lines 149..155

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

            if (params.recently === 'created') {
              uri = '/companies/v2/companies/recent/created'
              selector = '!.results.*'
            } else if (params.recently === 'updated') {
              uri = '/companies/v2/companies/recent/modified'
          Severity: Major
          Found in lib/collections/companies.js and 1 other location - About 1 hr to fix
          lib/collections/deals.js on lines 186..192

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

          const dealsQueryMapping = config.mapping.query.extended((mapping) => mapping
            .remap('since', (value) => ({ since: moment(value).valueOf() }))
          )
          Severity: Major
          Found in lib/collections/deals.js and 1 other location - About 1 hr to fix
          lib/collections/companies.js on lines 140..142

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

          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

          const companiesQueryMapping = config.mapping.query.extended((mapping) => mapping
            .remap('since', (value) => ({ since: moment(value).valueOf() }))
          )
          Severity: Major
          Found in lib/collections/companies.js and 1 other location - About 1 hr to fix
          lib/collections/deals.js on lines 174..176

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

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

          function responseHandlerFactory (params) {
            return (response, request) => {
              if (response.statusCode === 429) {
                let body = ''
                request
          Severity: Minor
          Found in lib/responseHandlerFactory.js - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language