bugsnag/bugsnag-js

View on GitHub
packages/react-native-cli/src/lib/__test__/Insert.test.ts

Summary

Maintainability
F
1 wk
Test Coverage

File Insert.test.ts has 291 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { insertJs, insertAndroid, insertIos } from '../Insert'
import logger from '../../Logger'
import path from 'path'
import { promises as fs } from 'fs'
import glob from 'glob'
Severity: Minor
Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts - About 3 hrs to fix

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

    test('insertAndroid(): already present (kotlin)', async () => {
      const globMock = glob as unknown as jest.MockedFunction<typeof glob>
      globMock.mockImplementation((glob, opts, cb) => cb(null, ['com/bugsnagreactnativeclitest/MainApplication.kt']))
    
      const mainApplication = await loadFixture(path.join(__dirname, 'fixtures', 'MainApplication-after.kt'))
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 1 other location - About 1 day to fix
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 276..294

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

    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

    test('insertAndroid(): already present (java)', async () => {
      const globMock = glob as unknown as jest.MockedFunction<typeof glob>
      globMock.mockImplementation((glob, opts, cb) => cb(null, ['com/bugsnagreactnativeclitest/MainApplication.java']))
    
      const mainApplication = await loadFixture(path.join(__dirname, 'fixtures', 'MainApplication-after.java'))
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 1 other location - About 1 day to fix
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 296..314

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

    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

    test('insertAndroid(): success (kotlin)', async () => {
      const globMock = glob as unknown as jest.MockedFunction<typeof glob>
      globMock.mockImplementation((glob, opts, cb) => cb(null, ['com/bugsnagreactnativeclitest/MainApplication.kt']))
    
      const mainApplication = await loadFixture(path.join(__dirname, 'fixtures', 'MainApplication-before.kt'))
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 3 other locations - About 1 day to fix
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 188..208
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 232..252
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 254..274

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

    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

    test('insertAndroid(): success (java)', async () => {
      const globMock = glob as unknown as jest.MockedFunction<typeof glob>
      globMock.mockImplementation((glob, opts, cb) => cb(null, ['com/bugsnagreactnativeclitest/MainApplication.java']))
    
      const mainApplication = await loadFixture(path.join(__dirname, 'fixtures', 'MainApplication-before.java'))
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 3 other locations - About 1 day to fix
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 210..230
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 232..252
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 254..274

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

    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

    test('insertAndroid(): success, tolerates some differences in source (java)', async () => {
      const globMock = glob as unknown as jest.MockedFunction<typeof glob>
      globMock.mockImplementation((glob, opts, cb) => cb(null, ['com/bugsnagreactnativeclitest/MainApplication.java']))
    
      const mainApplication = await loadFixture(path.join(__dirname, 'fixtures', 'MainApplication-before-2.java'))
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 3 other locations - About 1 day to fix
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 188..208
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 210..230
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 254..274

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

    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

    test('insertAndroid(): success, tolerates some differences in source (kotlin)', async () => {
      const globMock = glob as unknown as jest.MockedFunction<typeof glob>
      globMock.mockImplementation((glob, opts, cb) => cb(null, ['com/bugsnagreactnativeclitest/MainApplication.kt']))
    
      const mainApplication = await loadFixture(path.join(__dirname, 'fixtures', 'MainApplication-before-2.kt'))
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 3 other locations - About 1 day to fix
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 188..208
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 210..230
    packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 232..252

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

    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

    test('insertJs(): success', async () => {
      const indexJs = await loadFixture(path.join(__dirname, 'fixtures', 'index-before.js'))
      const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
      readFileMock.mockResolvedValue(indexJs)
    
    
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 1 other location - About 7 hrs to fix
    packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 90..103

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

    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

    jest.mock('fs', () => {
      return { promises: { readFile: jest.fn(), writeFile: jest.fn(), readdir: jest.fn() } }
    })
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 1 other location - About 1 hr to fix
    packages/react-native-cli/src/lib/__test__/InfoPlist.test.ts on lines 19..21

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

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

    async function generateNotFoundError () {
      try {
        await jest.requireActual('fs').promises.readFile(path.join(__dirname, 'does-not-exist.txt'))
      } catch (e) {
        return e
    Severity: Major
    Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 5 other locations - About 1 hr to fix
    packages/react-native-cli/src/lib/__test__/AndroidManifest.test.ts on lines 10..16
    packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 10..16
    packages/react-native-cli/src/lib/__test__/InfoPlist.test.ts on lines 10..16
    packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 7..13
    packages/react-native-cli/src/lib/__test__/Pod.test.ts on lines 11..17

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

    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

    There are no issues that match your filters.

    Category
    Status