Showing 313 of 321 total issues

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

    describe('getUserGroups', () => {
        it('should return a promise', () => {
            expect(currentUser.getUserGroups()).toBeInstanceOf(Promise)
        })

Severity: Major
Found in src/current-user/__tests__/CurrentUser.spec.js and 1 other location - About 3 hrs to fix
src/current-user/__tests__/CurrentUser.spec.js on lines 172..185

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

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 only the properties that have a translatableKey', () => {
            const dataElementSchema = fixtures.get('/api/schemas/dataElement')
            dataElementSchema.properties = dataElementSchema.properties.map(
                ({ translationKey, ...props }) => ({ ...props })
            )
Severity: Major
Found in src/model/__tests__/ModelDefinition.spec.js and 1 other location - About 3 hrs to fix
src/model/__tests__/ModelDefinition.spec.js on lines 1503..1515

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

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 only the properties that have a translatableKey', () => {
            const dataElementSchema = fixtures.get('/api/schemas/dataElement')
            dataElementSchema.properties = dataElementSchema.properties.map(
                ({ translationKey, ...props }) => ({ ...props })
            )
Severity: Major
Found in src/model/__tests__/ModelDefinition.spec.js and 1 other location - About 3 hrs to fix
src/model/__tests__/ModelDefinition.spec.js on lines 1544..1556

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

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 handle responses in plain text format', () => {
            fetchMock.mockReturnValueOnce(
                Promise.resolve({
                    ok: true,
                    text: () => Promise.resolve('this is not valid json'),
Severity: Major
Found in src/api/__tests__/Api.spec.js and 1 other location - About 3 hrs to fix
src/api/__tests__/Api.spec.js on lines 151..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 105.

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 false for white space strings', () => {
            expect(check.isNumeric(' ')).toBe(false)
            expect(check.isNumeric('\t')).toBe(false)
            expect(check.isNumeric('\n')).toBe(false)
            expect(check.isNumeric('\n\r')).toBe(false)
Severity: Major
Found in src/lib/__tests__/check.spec.js and 1 other location - About 3 hrs to fix
src/lib/__tests__/check.spec.js on lines 81..86

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

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 false for white space strings', () => {
            expect(check.isInteger(' ')).toBe(false)
            expect(check.isInteger('\t')).toBe(false)
            expect(check.isInteger('\n')).toBe(false)
            expect(check.isInteger('\n\r')).toBe(false)
Severity: Major
Found in src/lib/__tests__/check.spec.js and 1 other location - About 3 hrs to fix
src/lib/__tests__/check.spec.js on lines 130..135

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

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 handle responses in JSON format', () => {
            fetchMock.mockReturnValueOnce(
                Promise.resolve({
                    ok: true,
                    text: () => Promise.resolve('"this is a JSON string"'),
Severity: Major
Found in src/api/__tests__/Api.spec.js and 1 other location - About 3 hrs to fix
src/api/__tests__/Api.spec.js on lines 136..149

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

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 throw an error if namespace does not exist on server', () => {
            const err = { httpStatusCode: 404 }
            apiMock.get.mockReturnValueOnce(Promise.reject(err))

            return expect(
Severity: Major
Found in src/datastore/__tests__/UserDataStore.spec.js and 1 other location - About 3 hrs to fix
src/datastore/__tests__/DataStore.spec.js on lines 60..69

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

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 throw an error if namespace does not exist on server', () => {
            const err = { httpStatusCode: 404 }
            apiMock.get.mockReturnValueOnce(Promise.reject(err))

            return expect(
Severity: Major
Found in src/datastore/__tests__/DataStore.spec.js and 1 other location - About 3 hrs to fix
src/datastore/__tests__/UserDataStore.spec.js on lines 60..69

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

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 POST to the API', () =>
            userSettings.set('mySetting', 'my value').then(() => {
                expect(userSettings.api.get).toHaveBeenCalledTimes(0)
                expect(userSettings.api.post).toHaveBeenCalledTimes(1)
                expect(userSettings.api.delete).toHaveBeenCalledTimes(0)
Severity: Major
Found in src/current-user/__tests__/UserSettings.spec.js and 1 other location - About 3 hrs to fix
src/current-user/__tests__/UserSettings.spec.js on lines 188..193

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

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 DELETE if the value is null or an empty string', () =>
            userSettings.set('mySetting', '').then(() => {
                expect(userSettings.api.get).toHaveBeenCalledTimes(0)
                expect(userSettings.api.post).toHaveBeenCalledTimes(0)
                expect(userSettings.api.delete).toHaveBeenCalledTimes(1)
Severity: Major
Found in src/current-user/__tests__/UserSettings.spec.js and 1 other location - About 3 hrs to fix
src/current-user/__tests__/UserSettings.spec.js on lines 181..186

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

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

import MockApi from '../../api/Api'
import I18n from '../I18n'

jest.mock('../../api/Api')

Severity: Minor
Found in src/i18n/__tests__/I18n.spec.js - About 3 hrs to fix

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

            it('Sets the dirty flag to false when an element is added and then removed', () => {
                expect(mcp.dirty).toBe(false)
                mcp.add(testModels[0])
                expect(mcp.dirty).toBe(true)
                mcp.remove(testModels[0])
    Severity: Major
    Found in src/model/__tests__/ModelCollectionProperty.spec.js and 1 other location - About 3 hrs to fix
    src/model/__tests__/ModelCollectionProperty.spec.js on lines 136..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 100.

    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('Sets the dirty flag to false when an element is removed and re-added', () => {
                expect(mcp.dirty).toBe(false)
                mcp.remove(testModels[0])
                expect(mcp.dirty).toBe(true)
                mcp.add(testModels[0])
    Severity: Major
    Found in src/model/__tests__/ModelCollectionProperty.spec.js and 1 other location - About 3 hrs to fix
    src/model/__tests__/ModelCollectionProperty.spec.js on lines 92..98

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

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

    import {
        getMonthNamesForLocale,
        formatAsISODate,
        getLastDateOfMonth,
        getFirstDateOfQuarter,
    Severity: Minor
    Found in src/period/parser.js - About 3 hrs to fix

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

          describe('for SixMonthlyApril periods', () => {
              it('should handle valid SixMonthlyApril periods', () => {
                  doPeriodTest('1981AprilS1')
                  doPeriodTest('1981AprilS2')
              })
      Severity: Major
      Found in src/period/__tests__/parser.spec.js and 1 other location - About 3 hrs to fix
      src/period/__tests__/parser.spec.js on lines 479..489

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

      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 SixMonthly periods', () => {
              it('should handle valid SixMonthly periods', () => {
                  doPeriodTest('1981S1')
                  doPeriodTest('1981S2')
              })
      Severity: Major
      Found in src/period/__tests__/parser.spec.js and 1 other location - About 3 hrs to fix
      src/period/__tests__/parser.spec.js on lines 490..500

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

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

      import fixtures from '../../__fixtures__/fixtures'
      import Model from '../Model'
      import ModelDefinition from '../ModelDefinition'
      
      describe('Model', () => {
      Severity: Minor
      Found in src/model/__tests__/Model.spec.js - About 3 hrs to fix

        Function request has a Cognitive Complexity of 22 (exceeds 5 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: Minor
        Found in src/api/Api.js - About 3 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

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

        import MockApi from '../../api/Api'
        import SystemConfiguration from '../SystemConfiguration'
        
        jest.mock('../../api/Api')
        
        
        Severity: Minor
        Found in src/system/__tests__/SystemConfiguration.spec.js - About 3 hrs to fix
          Severity
          Category
          Status
          Source
          Language