Showing 313 of 321 total issues

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

        describe('.withAggregationType()', () => {
            it('should add the aggregationType parameter with the specified value', () => {
                request.withAggregationType('SUM')

                expect(request.parameters).toEqual({ aggregationType: 'SUM' })
Severity: Major
Found in src/analytics/__tests__/AnalyticsRequest.spec.js and 6 other locations - About 6 hrs to fix
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 530..552
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 554..572
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 574..594
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 596..616
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 638..660
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 662..682

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

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

        describe('.withDisplayProperty()', () => {
            it('should add the displayProperty parameter with the specified value', () => {
                request.withDisplayProperty('NAME')

                expect(request.parameters).toEqual({ displayProperty: 'NAME' })
Severity: Major
Found in src/analytics/__tests__/AnalyticsRequest.spec.js and 6 other locations - About 6 hrs to fix
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 506..528
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 554..572
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 574..594
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 596..616
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 638..660
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 662..682

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

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

        describe('.withOutputType()', () => {
            it('should add the outputType parameter with the specified value', () => {
                request.withOutputType('EVENT')

                expect(request.parameters).toEqual({ outputType: 'EVENT' })
Severity: Major
Found in src/analytics/__tests__/AnalyticsRequest.spec.js and 6 other locations - About 6 hrs to fix
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 506..528
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 530..552
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 554..572
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 596..616
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 638..660
src/analytics/__tests__/AnalyticsRequest.spec.js on lines 662..682

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

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 d2.spec.js has 420 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import Api from '../api/Api'
import fixtures from '../__fixtures__/fixtures'
import I18n from '../i18n/I18n'
import DataStore from '../datastore/DataStore'
import Logger from '../logger/Logger'
Severity: Minor
Found in src/__tests__/d2.spec.js - About 6 hrs to fix

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

    import { createPeriodGeneratorsForLocale } from '..'
    import * as daily from '../daily'
    import * as weekly from '../weekly'
    import * as monthly from '../monthly'
    import * as bimonthly from '../bi-monthly'
    Severity: Minor
    Found in src/period/generators/__tests__/index.spec.js - About 5 hrs to fix

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

              describe('.addPeriodDimension()', () => {
                  it('should add the pe dimension', () => {
                      request.addPeriodDimension('2017-01')
      
                      expect(request.dimensions).toEqual([
      Severity: Major
      Found in src/analytics/__tests__/AnalyticsRequest.spec.js and 1 other location - About 5 hrs to fix
      src/analytics/__tests__/AnalyticsRequest.spec.js on lines 237..258

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

      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

              describe('.addPeriodFilter()', () => {
                  it('should add the pe dimension filter', () => {
                      request.addPeriodFilter('2017-01')
      
                      expect(request.filters).toEqual([
      Severity: Major
      Found in src/analytics/__tests__/AnalyticsRequest.spec.js and 1 other location - About 5 hrs to fix
      src/analytics/__tests__/AnalyticsRequest.spec.js on lines 140..161

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

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

          request(method, url, data, options = {}) {
              checkType(method, 'string', 'Request type')
              checkType(url, 'string', 'Url')
              const api = this
              let requestUrl = url
      Severity: Major
      Found in src/api/Api.js - About 5 hrs to fix

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

        import fixtures from '../../__fixtures__/fixtures'
        import Api from '../../api/Api'
        import Model from '../Model'
        import ModelDefinition from '../ModelDefinition'
        import ModelCollectionProperty from '../ModelCollectionProperty'
        Severity: Minor
        Found in src/model/__tests__/ModelCollectionProperty.spec.js - About 5 hrs to fix

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

                  it('should return a UserDatastoreNamespace with keys if it exists', () => {
                      apiMock.get
                          .mockReturnValueOnce(Promise.resolve(namespaces))
                          .mockReturnValueOnce(Promise.resolve(keys))
          
          
          Severity: Major
          Found in src/datastore/__tests__/UserDataStore.spec.js and 1 other location - About 4 hrs to fix
          src/datastore/__tests__/DataStore.spec.js on lines 31..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 130.

          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 return a datastorenamespace with keys if it exists', () => {
                      apiMock.get
                          .mockReturnValueOnce(Promise.resolve(namespaces))
                          .mockReturnValueOnce(Promise.resolve(keys))
          
          
          Severity: Major
          Found in src/datastore/__tests__/DataStore.spec.js and 1 other location - About 4 hrs to fix
          src/datastore/__tests__/UserDataStore.spec.js on lines 31..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 130.

          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

                  describe('for an invalid namespace', () => {
                      beforeEach(() => {
                          apiMock.get.mockReturnValueOnce(
                              Promise.reject(
                                  [
          Severity: Major
          Found in src/datastore/__tests__/DataStore.spec.js and 1 other location - About 4 hrs to fix
          src/datastore/__tests__/UserDataStore.spec.js on lines 93..117

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

          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

                  describe('for an invalid namespace', () => {
                      beforeEach(() => {
                          apiMock.get.mockReturnValueOnce(
                              Promise.reject(
                                  [
          Severity: Major
          Found in src/datastore/__tests__/UserDataStore.spec.js and 1 other location - About 4 hrs to fix
          src/datastore/__tests__/DataStore.spec.js on lines 80..104

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

          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 ModelDefinition.js has 357 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import { checkType, isObject, checkDefined, isDefined } from '../lib/check'
          import {
              addLockedProperty,
              curry,
              copyOwnProperties,
          Severity: Minor
          Found in src/model/ModelDefinition.js - About 4 hrs to fix

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

                FinancialJuly: (match, locale = 'en') => {
                    const year = parseInt(match[1], 10)
                    const monthNames = getMonthNamesForLocale(locale)
                    return {
                        id: match[0],
            Severity: Major
            Found in src/period/parser.js and 3 other locations - About 4 hrs to fix
            src/period/parser.js on lines 258..267
            src/period/parser.js on lines 278..287
            src/period/parser.js on lines 288..297

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

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

                FinancialNov: (match, locale = 'en') => {
                    const year = parseInt(match[1], 10)
                    const monthNames = getMonthNamesForLocale(locale)
                    return {
                        id: match[0],
            Severity: Major
            Found in src/period/parser.js and 3 other locations - About 4 hrs to fix
            src/period/parser.js on lines 258..267
            src/period/parser.js on lines 268..277
            src/period/parser.js on lines 278..287

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

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

                FinancialOct: (match, locale = 'en') => {
                    const year = parseInt(match[1], 10)
                    const monthNames = getMonthNamesForLocale(locale)
                    return {
                        id: match[0],
            Severity: Major
            Found in src/period/parser.js and 3 other locations - About 4 hrs to fix
            src/period/parser.js on lines 258..267
            src/period/parser.js on lines 268..277
            src/period/parser.js on lines 288..297

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

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

                FinancialApril: (match, locale = 'en') => {
                    const year = parseInt(match[1], 10)
                    const monthNames = getMonthNamesForLocale(locale)
                    return {
                        id: match[0],
            Severity: Major
            Found in src/period/parser.js and 3 other locations - About 4 hrs to fix
            src/period/parser.js on lines 268..277
            src/period/parser.js on lines 278..287
            src/period/parser.js on lines 288..297

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

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

            export default (function x() {
                const fixtures = {}
            
                function getFixture(fixtureName) {
                    if (fixtures && fixtures[fixtureName]) {
            Severity: Major
            Found in src/__fixtures__/fixtures.js - About 4 hrs to fix

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

                  describe('delete()', () => {
                      beforeEach(() => {
                          apiMock.delete.mockReturnValueOnce(Promise.resolve())
                      })
              
              
              Severity: Major
              Found in src/datastore/__tests__/DataStore.spec.js and 1 other location - About 4 hrs to fix
              src/datastore/__tests__/UserDataStore.spec.js on lines 142..156

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

              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