bugsnag/bugsnag-js

View on GitHub

Showing 191 of 352 total issues

Function createRendererClient has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createRendererClient = (rendererOpts) => {
  if (!window.__bugsnag_ipc__) throw new Error('Bugsnag was not loaded in the main process')

  const internalPlugins = [
    require('@bugsnag/plugin-electron-renderer-client-state-updates')(window.__bugsnag_ipc__),
Severity: Minor
Found in packages/electron/src/client/renderer.js - About 1 hr to fix

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

      load: (client) => {
        client.addOnBreadcrumb(breadcrumb => {
          try {
            BugsnagIpcRenderer.leaveBreadcrumb(Object.assign({}, breadcrumb))
          } catch (e) {

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

          load: (client) => {
            if (!isEnabledFor(client)) {
              return
            }
      
      

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

          buildIOS: function buildIOS () {
            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 deserialiseEvent has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function deserialiseEvent (json, minidumpPath) {
            if (!json || typeof json !== 'object') {
              return
            }
          
          
          Severity: Minor
          Found in packages/plugin-electron-deliver-minidumps/event-serialisation.js - About 1 hr to fix

            Function load has 45 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-restify/src/restify.js - About 1 hr to fix

              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

                  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

                                    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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language