bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

Function exports has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = req => {
  const connection = req.connection
  const address = connection && connection.address && connection.address()
  const portNumber = address && address.port
  const port = (!portNumber || portNumber === 80 || portNumber === 443) ? '' : `:${portNumber}`
Severity: Minor
Found in packages/plugin-express/src/request-info.js - About 1 hr to fix

    Function exports has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = (callbacks, event, onCallbackError, cb) => {
      // This function is how we support different kinds of callback:
      //  - synchronous - return value
      //  - node-style async with callback - cb(err, value)
      //  - promise/thenable - resolve(value)
    Severity: Minor
    Found in packages/core/lib/callback-runner.js - About 1 hr to fix

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

        load: (client) => {
          if (!client._config.autoDetectErrors) return
          if (!client._config.enabledErrorTypes.unhandledExceptions) return
          function onerror (messageOrEvent, url, lineNo, charNo, error) {
            // Ignore errors with no info due to CORS settings
      Severity: Minor
      Found in packages/plugin-window-onerror/onerror.js - About 1 hr to fix

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

            client.setContext = (...args) => {
              const ret = origSetContext.call(client, ...args)
              emitter.emit('ContextUpdate', client.getContext())
              return ret
            }
        packages/plugin-electron-client-state-manager/client-state-manager.js on lines 12..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 59.

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

        export async function configure (projectRoot: string, options: Options, logger: Logger): Promise<void> {
          const manifestPath = path.join(projectRoot, 'android', 'app', 'src', 'main', 'AndroidManifest.xml')
        
          try {
            const manifest = await fs.readFile(manifestPath, 'utf8')
        Severity: Minor
        Found in packages/react-native-cli/src/lib/AndroidManifest.ts - About 1 hr to fix

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

              client.setUser = (...args) => {
                const ret = origSetUser.call(client, ...args)
                emitter.emit('UserUpdate', client.getUser())
                return ret
              }
          packages/plugin-electron-client-state-manager/client-state-manager.js on lines 19..23

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

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

          module.exports = req => {
            const connection = req.connection
            const address = connection && connection.address && connection.address()
            const portNumber = address && address.port
            const path = req.getPath() || req.url
          Severity: Minor
          Found in packages/plugin-restify/src/request-info.js - About 1 hr to fix

            Function request has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                net.request = (...args) => {
                  const request = originalRequest.apply(net, args)
            
                  // grab the final URL from the internal "_urlLoaderOptions" - there is some
                  // processing of the raw URL that we don't want to have to replicate here
            Severity: Minor
            Found in packages/plugin-electron-net-breadcrumbs/net-breadcrumbs.js - About 1 hr to fix

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

                load: (client) => {
                  // Do not attach any listeners if autoDetectErrors is disabled or unhandledRejections are not an enabled error type
                  if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes.unhandledRejections) return () => { }
              
                  // Check if Hermes is available and is being used for promises

                Function getSuggestedBugsnagGradleVersion has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export async function getSuggestedBugsnagGradleVersion (projectRoot: string, logger: Logger): Promise<string> {
                  let fileContents: string
                  try {
                    fileContents = await fs.readFile(path.join(projectRoot, 'android', 'build.gradle'), 'utf8')
                  } catch (e) {
                Severity: Minor
                Found in packages/react-native-cli/src/lib/Gradle.ts - About 1 hr to fix

                  Function modifyAppBuildGradle has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export async function modifyAppBuildGradle (projectRoot: string, logger: Logger): Promise<void> {
                    logger.debug('Looking for android/app/build.gradle')
                    const appBuildGradlePath = path.join(projectRoot, 'android', 'app', 'build.gradle')
                    logger.debug('Applying com.bugsnag.android.gradle plugin')
                  
                  
                  Severity: Minor
                  Found in packages/react-native-cli/src/lib/Gradle.ts - About 1 hr to fix

                    Function modifyRootBuildGradle has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export async function modifyRootBuildGradle (projectRoot: string, pluginVersion: string, logger: Logger): Promise<void> {
                      logger.debug('Looking for android/build.gradle')
                      const topLevelBuildGradlePath = path.join(projectRoot, 'android', 'build.gradle')
                      logger.debug('Adding \'bugsnag-android-gradle-plugin\' to the build script classpath')
                      try {
                    Severity: Minor
                    Found in packages/react-native-cli/src/lib/Gradle.ts - About 1 hr to fix

                      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

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

                      async function generateNotFoundError () {
                        try {
                          await jest.requireActual('fs').promises.readdir(path.join(__dirname, 'does-not-exist'))
                        } catch (e) {
                          return e
                      Severity: Major
                      Found in packages/react-native-cli/src/lib/__test__/Pod.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__/Npm.test.ts on lines 7..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 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

                      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__/Gradle.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__/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__/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

                      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
                      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__/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

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

                      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

                      Function runMaybeAsyncCallback has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        const runMaybeAsyncCallback = (fn, cb) => {
                          if (typeof fn !== 'function') return cb(null)
                          try {
                            // if function appears sync…
                            if (fn.length !== 2) {
                      Severity: Minor
                      Found in packages/core/lib/callback-runner.js - About 1 hr to fix

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

                            load (client) {
                              if (!client._isBreadcrumbTypeEnabled(BREADCRUMB_STATE)) {
                                return
                              }
                        
                        
                        Severity: Minor
                        Found in packages/plugin-electron-screen-breadcrumbs/screen-breadcrumbs.js - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language