bugsnag/bugsnag-js

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

Summary

Maintainability
F
3 days
Test Coverage

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

test('install(): npm success - dev', async () => {
  const spawnMock = spawn as jest.MockedFunction<typeof spawn>
  spawnMock.mockImplementation(() => {
    const ee = new EventEmitter() as ChildProcess
    process.nextTick(() => ee.emit('close', 0))
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Npm.test.ts and 2 other locations - About 5 hrs to fix
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 65..74
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 121..130

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

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

test('install(): npm success', async () => {
  const spawnMock = spawn as jest.MockedFunction<typeof spawn>
  spawnMock.mockImplementation(() => {
    const ee = new EventEmitter() as ChildProcess
    process.nextTick(() => ee.emit('close', 0))
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Npm.test.ts and 2 other locations - About 5 hrs to fix
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 87..96
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 121..130

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

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

test('install(): yarn success - dev', async () => {
  const spawnMock = spawn as jest.MockedFunction<typeof spawn>
  spawnMock.mockImplementation(() => {
    const ee = new EventEmitter() as ChildProcess
    process.nextTick(() => ee.emit('close', 0))
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Npm.test.ts and 2 other locations - About 5 hrs to fix
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 65..74
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 87..96

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

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

test('detectInstalled(): not installed', async () => {
  const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
  readFileMock.mockResolvedValue('{"dependencies": { "react-native": "~1.0.0"} }')
  expect(await detectInstalled('@bugsnag/test-package', '/example/dir')).toBe(false)
  expect(readFileMock).toHaveBeenCalledWith('/example/dir/package.json', 'utf8')
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Npm.test.ts and 2 other locations - About 2 hrs to fix
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 36..41
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 43..48

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

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

test('detectInstalled(): installed in dev deps', async () => {
  const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
  readFileMock.mockResolvedValue('{"devDependencies": { "@bugsnag/test-package": "~1.0.0"} }')
  expect(await detectInstalled('@bugsnag/test-package', '/example/dir')).toBe(true)
  expect(readFileMock).toHaveBeenCalledWith('/example/dir/package.json', 'utf8')
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Npm.test.ts and 2 other locations - About 2 hrs to fix
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 36..41
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 50..55

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

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

test('detectInstalled(): installed in deps', async () => {
  const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
  readFileMock.mockResolvedValue('{"dependencies": { "@bugsnag/test-package": "~1.0.0"} }')
  expect(await detectInstalled('@bugsnag/test-package', '/example/dir')).toBe(true)
  expect(readFileMock).toHaveBeenCalledWith('/example/dir/package.json', 'utf8')
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Npm.test.ts and 2 other locations - About 2 hrs to fix
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 43..48
packages/react-native-cli/src/lib/__test__/Npm.test.ts on lines 50..55

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

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__/Npm.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__/Insert.test.ts on lines 11..17
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

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

jest.mock('fs', () => {
  return { promises: { readFile: jest.fn(), writeFile: jest.fn() } }
})
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Npm.test.ts and 2 other locations - About 50 mins to fix
packages/react-native-cli/src/lib/__test__/AndroidManifest.test.ts on lines 19..21
packages/react-native-cli/src/lib/__test__/Gradle.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 51.

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