bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

Function attachBrowserWindowListeners has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function attachBrowserWindowListeners (leaveBreadcrumb, browserWindow) {
  // the moved event fires too frequently to add a breadcrumb each time
  const onMoved = debounce(() => {
    // it's possible for the window to be destroyed at this point because we
    // debounce this callback. If we try to use 'getPosition' when the window is
Severity: Minor
Found in packages/plugin-electron-app-breadcrumbs/app-breadcrumbs.js - About 1 hr to fix

    Function getIdentifier has 45 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getIdentifier = (filepath) => {
      const key = Buffer.from(lookupKey)
      // Align to nearest 8 bytes:
      // offset = {length rounded up to nearest multiple of 8}
      const byteOffset = (lookupKeyLength | 0x7) + 1
    Severity: Minor
    Found in packages/electron-filestore/lib/minidump-io.js - About 1 hr to fix

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

      function humanReadableOptions (options: Options): string {
        return Object.keys(options)
          .map(key => HUMAN_READABLE_PROPERTY_NAMES[key as keyof Options])
          .join(', ')
          .replace(/,(?=[^,]*$)/, ' and')
      Severity: Major
      Found in packages/react-native-cli/src/lib/AndroidManifest.ts and 1 other location - About 1 hr to fix
      packages/react-native-cli/src/lib/InfoPlist.ts on lines 110..115

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

      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

      function humanReadableOptions (options: Options): string {
        return Object.keys(options)
          .map(key => HUMAN_READABLE_PROPERTY_NAMES[key as keyof Options])
          .join(', ')
          .replace(/,(?=[^,]*$)/, ' and')
      Severity: Major
      Found in packages/react-native-cli/src/lib/InfoPlist.ts and 1 other location - About 1 hr to fix
      packages/react-native-cli/src/lib/AndroidManifest.ts on lines 87..92

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

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

      const createMainClient = (opts) => {
        // check api key has been provided as we need it to create the FileStore
        // which happens before the API key is validated
        if (typeof opts.apiKey !== 'string') {
          throw new Error('No Bugsnag API Key set')
      Severity: Minor
      Found in packages/electron/src/client/main.js - About 1 hr to fix

        Function sendSessionSummary has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

        const sendSessionSummary = client => sessionCounts => {
          // exit early if the current releaseStage is not enabled
          if (client._config.enabledReleaseStages !== null && !client._config.enabledReleaseStages.includes(client._config.releaseStage)) {
            client._logger.warn('Session not sent due to releaseStage/enabledReleaseStages configuration')
            return
        Severity: Minor
        Found in packages/plugin-server-session/session.js - About 1 hr 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 14 (exceeds 5 allowed). Consider refactoring.
        Open

        module.exports = (source = process) => ({
          load: (client) => {
            client.addOnError(function (event) {
              const info = {}
              if (typeof source.getHeapStatistics === 'function') {
        Severity: Minor
        Found in packages/plugin-electron-process-info/procinfo.js - About 1 hr 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 43 lines of code (exceeds 25 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 1 hr to fix

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

            load: client => {
              const requestHandler = async (ctx, next) => {
                // Get a client to be scoped to this request. If sessions are enabled, use the
                // resumeSession() call to get a session client, otherwise, clone the existing client.
                const requestClient = client._config.autoTrackSessions ? client.resumeSession() : clone(client)
          Severity: Minor
          Found in packages/plugin-koa/src/koa.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                    } else if (
                      // This complex case detects "error" events that are typically synthesised
                      // by jquery's trigger method (although can be created in other ways). In
                      // order to detect this:
                      // - the first argument (message) must exist and be an object (most likely it's a jQuery event)
            Severity: Critical
            Found in packages/plugin-window-onerror/onerror.js - About 1 hr to fix

              Function buildAndroid has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                buildAndroid: function buildAndroid (sourceFixtures, destFixtures) {
                  try {
                    const version = process.env.NOTIFIER_VERSION || common.determineVersion()
                    const rnVersion = process.env.REACT_NATIVE_VERSION
                    const registryUrl = process.env.REGISTRY_URL
              Severity: Minor
              Found in scripts/react-native-helper.js - About 1 hr to fix

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

                  load (client) {
                    if (!client._isBreadcrumbTypeEnabled(BREADCRUMB_REQUEST)) {
                      return
                    }
                
                
                Severity: Minor
                Found in packages/plugin-electron-net-breadcrumbs/net-breadcrumbs.js - About 1 hr to fix

                  Function insertIos has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export async function insertIos (projectRoot: string, logger: Logger): Promise<void> {
                    logger.info('Adding Bugsnag to the iOS layer')
                  
                    const iosDir = path.join(projectRoot, 'ios')
                    let appDelegatePath
                  Severity: Minor
                  Found in packages/react-native-cli/src/lib/Insert.ts - About 1 hr to fix

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

                      load: client => {
                        const requestHandler = (req, res, next) => {
                          const dom = domain.create()
                    
                          // Get a client to be scoped to this request. If sessions are enabled, use the
                    Severity: Minor
                    Found in packages/plugin-express/src/express.js - About 1 hr to fix

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

                      module.exports = screen => {
                        const seenIds = []
                      
                        const anonymiseId = id => {
                          if (!seenIds.includes(id)) {
                      Severity: Minor
                      Found in packages/plugin-electron-screen-breadcrumbs/screen-breadcrumbs.js - About 1 hr to fix

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

                        const setDefaultUserId = (eventOrSession) => {
                          // device id is also used to populate the user id field, if it's not already set
                          const user = eventOrSession.getUser()
                          if (!user || !user.id) {
                            eventOrSession.setUser(eventOrSession.device.id)
                        Severity: Major
                        Found in packages/plugin-browser-device/device.js and 1 other location - About 1 hr to fix
                        packages/plugin-electron-device/device.js on lines 142..148

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

                        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 setDefaultUserId = (eventOrSession) => {
                              // device id is also used to populate the user id field, if it's not already set
                              const user = eventOrSession.getUser()
                              if (!user || !user.id) {
                                eventOrSession.setUser(eventOrSession.device.id)
                        Severity: Major
                        Found in packages/plugin-electron-device/device.js and 1 other location - About 1 hr to fix
                        packages/plugin-browser-device/device.js on lines 75..81

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

                        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 13 (exceeds 5 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

                        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 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                        module.exports = (app, client) => {
                          const prev = app.config.errorHandler
                        
                          const handler = (err, vm, info) => {
                            const handledState = { severity: 'error', unhandled: true, severityReason: { type: 'unhandledException' } }
                        Severity: Minor
                        Found in packages/plugin-vue/src/vue.js - About 1 hr 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 _configure has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                        Open

                          _configure (opts, internalPlugins) {
                            const schema = reduce(internalPlugins, (schema, plugin) => {
                              if (plugin && plugin.configSchema) return assign({}, schema, plugin.configSchema)
                              return schema
                            }, this._schema)
                        Severity: Minor
                        Found in packages/core/client.js - About 1 hr 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

                        Severity
                        Category
                        Status
                        Source
                        Language