bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

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

package com.bugsnagreactnativeclitest

import com.bugsnag.android.Bugsnag
import android.app.Application
import com.facebook.react.PackageList
packages/react-native-cli/src/lib/__test__/fixtures/MainApplication-after-2.kt on lines 1..49

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

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

package com.bugsnagreactnativeclitest

import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
packages/react-native-cli/src/lib/__test__/fixtures/MainApplication-before-2.kt on lines 1..47

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

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

package com.bugsnagreactnativeclitest

import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
packages/react-native-cli/src/lib/__test__/fixtures/MainApplication-before.kt on lines 1..46

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

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('detectState(): no repo', async () => {
  const spawnSyncMock = (spawnSync as unknown as jest.MockedFunction<spawnSyncFn>)
  spawnSyncMock.mockReturnValue({
    status: 128,
    signal: null,
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Repo.test.ts and 2 other locations - About 5 hrs to fix
packages/react-native-cli/src/lib/__test__/Repo.test.ts on lines 31..48
packages/react-native-cli/src/lib/__test__/Repo.test.ts on lines 50..67

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

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('detectState(): clean repo', async () => {
  const spawnSyncMock = (spawnSync as unknown as jest.MockedFunction<spawnSyncFn>)
  spawnSyncMock.mockReturnValue({
    status: 0,
    signal: null,
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Repo.test.ts and 2 other locations - About 5 hrs to fix
packages/react-native-cli/src/lib/__test__/Repo.test.ts on lines 12..29
packages/react-native-cli/src/lib/__test__/Repo.test.ts on lines 31..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 141.

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('detectState(): dirty repo', async () => {
  const spawnSyncMock = (spawnSync as unknown as jest.MockedFunction<spawnSyncFn>)
  spawnSyncMock.mockReturnValue({
    status: 0,
    signal: null,
Severity: Major
Found in packages/react-native-cli/src/lib/__test__/Repo.test.ts and 2 other locations - About 5 hrs to fix
packages/react-native-cli/src/lib/__test__/Repo.test.ts on lines 12..29
packages/react-native-cli/src/lib/__test__/Repo.test.ts on lines 50..67

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

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

  methods.forEach((m) => {
    if (/^_/.test(m)) return
    Bugsnag[m] = function () {
      if (!Bugsnag._client) return console.error(`Bugsnag.${m}() was called before Bugsnag.start()`)
      Bugsnag._client._depth += 1
Severity: Major
Found in packages/electron/src/client/createClient.js and 1 other location - About 5 hrs to fix
packages/react-native/src/notifier.js on lines 155..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 137.

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

CLIENT_METHODS.forEach((m) => {
  if (/^_/.test(m)) return
  Bugsnag[m] = function () {
    if (!Bugsnag._client) return console.warn(`Bugsnag.${m}() was called before Bugsnag.start()`)
    Bugsnag._client._depth += 1
Severity: Major
Found in packages/react-native/src/notifier.js and 1 other location - About 5 hrs to fix
packages/electron/src/client/createClient.js on lines 39..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 137.

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

module.exports = (_ignoredUrls = [], win = window) => {
  let restoreFunctions = []
  const plugin = {
    load: client => {
      if (!client._isBreadcrumbTypeEnabled('request')) return
Severity: Major
Found in packages/plugin-network-breadcrumbs/network-breadcrumbs.js - About 5 hrs to fix

    Function load has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

      load (client) {
        const leaveBreadcrumb = (event, currentRouteName, previousRouteName) => {
          if (!client._isBreadcrumbTypeEnabled('navigation')) return
    
          client.leaveBreadcrumb(
    Severity: Minor
    Found in packages/plugin-react-navigation/react-navigation.js - About 4 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

    Function load has 116 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      load: (client) => {
        if (!client._config.trackInlineScripts) return
    
        const originalLocation = win.location.href
        let html = ''
    Severity: Major
    Found in packages/plugin-inline-script-content/inline-script-content.js - About 4 hrs to fix

      Function delivery has 115 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const delivery = (client, filestore, net, app) => {
        const noop = () => {}
      
        const send = (opts, body, cb) => {
          let errorCallback = (error, response) => {
      Severity: Major
      Found in packages/delivery-electron/delivery.js - About 4 hrs to fix

        Function load has 115 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            load: client => {
              if (!client._isBreadcrumbTypeEnabled('request')) return
        
              const ignoredUrls = [
                client._config.endpoints.notify,
        Severity: Major
        Found in packages/plugin-network-breadcrumbs/network-breadcrumbs.js - About 4 hrs to fix

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

          package com.bugsnag.android;
          
          import androidx.annotation.NonNull;
          
          import com.facebook.react.bridge.Promise;
          packages/react-native/android/src/oldarch/java/com/bugsnag/android/BugsnagReactNative.java on lines 1..134

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

          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

          package com.bugsnag.android;
          
          import androidx.annotation.NonNull;
          import androidx.annotation.Nullable;
          import com.facebook.react.bridge.Arguments;
          packages/react-native/android/src/newarch/java/com/bugsnag/android/NativeBugsnagImpl.java on lines 1..128

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

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

          const delivery = (client, filestore, net, app) => {
            const noop = () => {}
          
            const send = (opts, body, cb) => {
              let errorCallback = (error, response) => {
          Severity: Minor
          Found in packages/delivery-electron/delivery.js - About 4 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

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

            constructor (...args) {
              // Fetch Vue from the window object, if it exists
              const globalVue = typeof window !== 'undefined' && window.Vue
          
              this.name = 'vue'
          Severity: Major
          Found in packages/plugin-vue/src/index.js and 1 other location - About 4 hrs to fix
          packages/plugin-react/src/index.js on lines 2..13

          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