bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

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

  constructor (...args) {
    // Fetch React from the window object, if it exists
    const globalReact = typeof window !== 'undefined' && window.React

    this.name = 'react'
Severity: Major
Found in packages/plugin-react/src/index.js and 1 other location - About 4 hrs to fix
packages/plugin-vue/src/index.js on lines 5..16

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

Function normaliseError has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

const normaliseError = (maybeError, tolerateNonErrors, component, logger) => {
  let error
  let internalFrames = 0

  const createAndLogInputError = (reason) => {
Severity: Minor
Found in packages/core/event.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 exports has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (client, win = window) => ({
  sendEvent: (event, cb = () => {}) => {
    try {
      const url = client._config.endpoints.notify
      const req = new win.XMLHttpRequest()
Severity: Minor
Found in packages/delivery-xml-http-request/delivery.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

Function exports has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = (win = window, component = 'window onerror') => ({
  load: (client) => {
    if (!client._config.autoDetectErrors) return
    if (!client._config.enabledErrorTypes.unhandledExceptions) return
    function onerror (messageOrEvent, url, lineNo, charNo, error) {
Severity: Minor
Found in packages/plugin-window-onerror/onerror.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

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

  load: (client) => {
    client.addOnBreadcrumb(breadcrumb => {
      // we copy the breadcrumb's properties over to a new object to ensure its
      // to JSON() method doesn't get called before passing the object over the
      // bridge. This happens in the remote debugger and means the "message"
Severity: Major
Found in packages/plugin-react-native-client-sync/client-sync.js - About 3 hrs to fix

    Client has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Client {
      constructor (configuration, schema = config.schema, internalPlugins = [], notifier) {
        // notifier id
        this._notifier = notifier
    
    
    Severity: Minor
    Found in packages/core/client.js - About 3 hrs to fix

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

        load (client) {
          const app = {}
          const lastRunInfo = filestore.getLastRunInfo()
          const updateApp = createAppUpdater(client, NativeClient, app)
          const updateNextCrashLastRunInfo = createLastRunInfoUpdater(client, NativeClient)
      Severity: Major
      Found in packages/plugin-electron-app/app.js - About 3 hrs to fix

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

        test('getSuggestedBugsnagGradleVersion(): success with bracketed AGP version', async () => {
          const buildGradle = await loadFixture(path.join(__dirname, 'fixtures', 'root-build-before-with-prefixed-agp-version.gradle'))
        
          const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
          readFileMock.mockResolvedValueOnce(buildGradle)
        Severity: Major
        Found in packages/react-native-cli/src/lib/__test__/Gradle.test.ts and 2 other locations - About 3 hrs to fix
        packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 486..494
        packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 496..504

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

        test('getSuggestedBugsnagGradleVersion(): success', async () => {
          const buildGradle = await loadFixture(path.join(__dirname, 'fixtures', 'root-build-before.gradle'))
        
          const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
          readFileMock.mockResolvedValueOnce(buildGradle)
        Severity: Major
        Found in packages/react-native-cli/src/lib/__test__/Gradle.test.ts and 2 other locations - About 3 hrs to fix
        packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 496..504
        packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 506..514

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

        test('getSuggestedBugsnagGradleVersion(): null with wrong file', async () => {
          const buildGradle = await loadFixture(path.join(__dirname, 'fixtures', 'app-build-before.gradle'))
        
          const readFileMock = fs.readFile as jest.MockedFunction<typeof fs.readFile>
          readFileMock.mockResolvedValueOnce(buildGradle)
        Severity: Major
        Found in packages/react-native-cli/src/lib/__test__/Gradle.test.ts and 2 other locations - About 3 hrs to fix
        packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 486..494
        packages/react-native-cli/src/lib/__test__/Gradle.test.ts on lines 506..514

        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

        Function exports has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = (win = window) => {
          const plugin = {
            load: (client) => {
              if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes.unhandledRejections) return
              const listener = evt => {
        Severity: Minor
        Found in packages/plugin-window-unhandled-rejection/unhandled-rejection.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

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

          load (client) {
            const device = {}
            let cachedDevice = {}
        
            try {
        Severity: Major
        Found in packages/plugin-electron-device/device.js - About 3 hrs to fix

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

          const getPrefixedConsole = () => {
            const logger = {}
            const consoleLog = console.log
            map(['debug', 'info', 'warn', 'error'], (method) => {
              const consoleMethod = console[method]
          Severity: Major
          Found in packages/browser/src/config.js and 1 other location - About 3 hrs to fix
          packages/web-worker/src/config.js on lines 28..38

          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

          const createAppUpdater = (client, NativeClient, app) => {
            if (!isNativeClientEnabled(client)) {
              return newProperties => Object.assign(app, newProperties)
            }
          
          
          Severity: Major
          Found in packages/plugin-electron-app/app.js and 1 other location - About 3 hrs to fix
          packages/plugin-electron-device/device.js on lines 12..26

          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

          const createDeviceUpdater = (client, NativeClient, device) => {
            if (!isNativeClientEnabled(client)) {
              return newProperties => Object.assign(device, newProperties)
            }
          
          
          Severity: Major
          Found in packages/plugin-electron-device/device.js and 1 other location - About 3 hrs to fix
          packages/plugin-electron-app/app.js on lines 15..29

          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

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

          const getPrefixedConsole = () => {
            const logger = {}
            const consoleLog = console.log
            map(['debug', 'info', 'warn', 'error'], (method) => {
              const consoleMethod = console[method]
          Severity: Major
          Found in packages/web-worker/src/config.js and 1 other location - About 3 hrs to fix
          packages/browser/src/config.js on lines 25..35

          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

              client.clearMetadata = (...args) => {
                const ret = origClearMetadata.call(client, ...args)
                const [section] = args
                if (typeof section === 'string') {
                  const values = client.getMetadata(section)
          packages/plugin-electron-client-state-manager/client-state-manager.js on lines 26..34

          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

              client.addMetadata = (...args) => {
                const ret = origAddMetadata.call(client, ...args)
                const [section] = args
                if (typeof section === 'string') {
                  const values = client.getMetadata(section)
          packages/plugin-electron-client-state-manager/client-state-manager.js on lines 37..45

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

            try {
              const appBuildGradlePath = path.join(projectRoot, 'android', 'app', 'build.gradle')
          
              await insertBugsnagConfigBlock(appBuildGradlePath, logger)
          
          
          Severity: Major
          Found in packages/react-native-cli/src/lib/Gradle.ts and 2 other locations - About 3 hrs to fix
          packages/react-native-cli/src/lib/Gradle.ts on lines 101..129
          packages/react-native-cli/src/lib/Gradle.ts on lines 219..259

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

          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

            try {
              const appBuildGradlePath = path.join(projectRoot, 'android', 'app', 'build.gradle')
          
              await insertBugsnagConfigBlock(appBuildGradlePath, logger)
          
          
          Severity: Major
          Found in packages/react-native-cli/src/lib/Gradle.ts and 2 other locations - About 3 hrs to fix
          packages/react-native-cli/src/lib/Gradle.ts on lines 101..129
          packages/react-native-cli/src/lib/Gradle.ts on lines 175..215

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

          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