bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

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

      requestClient.addOnError((event) => {
        const { request, metadata } = getRequestAndMetadataFromCtx(ctx)
        event.request = { ...event.request, ...request }
        event.addMetadata('request', metadata)
      }, true)
Severity: Major
Found in packages/plugin-koa/src/koa.js and 2 other locations - About 2 hrs to fix
packages/plugin-express/src/express.js on lines 28..32
packages/plugin-restify/src/restify.js on lines 27..31

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

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

module.exports = (net, client) => {
  const send = (opts, formData) => {
    return new Promise((resolve, reject) => {
      const req = net.request(opts, response => {
        response.on('error', reject)
Severity: Major
Found in packages/plugin-electron-deliver-minidumps/send-minidump.js - About 2 hrs to fix

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

      load (client) {
        if (!client._isBreadcrumbTypeEnabled(BREADCRUMB_STATE)) {
          return
        }
    
    
    Severity: Minor
    Found in packages/plugin-electron-app-breadcrumbs/app-breadcrumbs.js - About 2 hrs to fix

      Function _notify has 50 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _notify (event, onError, postReportCallback = noop) {
          event.app = assign({}, event.app, {
            releaseStage: this._config.releaseStage,
            version: this._config.appVersion,
            type: this._config.appType
      Severity: Minor
      Found in packages/core/client.js - About 2 hrs to fix

        Function configure has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export async function configure (projectRoot: string, options: Options, logger: Logger): Promise<void> {
          const iosDir = path.join(projectRoot, 'ios')
        
          let xcodeprojDir
        
        
        Severity: Minor
        Found in packages/react-native-cli/src/lib/InfoPlist.ts - About 1 hr to fix

          Function run has 49 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export default async function run (projectRoot: string, urls: OnPremiseUrls): Promise<boolean> {
            try {
              const { bugsnagCliIntegration } = await prompts({
                type: 'confirm',
                name: 'bugsnagCliIntegration',

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

              start: (opts) => {
                if (Bugsnag._client) {
                  Bugsnag._client._logger.warn('Bugsnag.start() was called more than once. Ignoring.')
                  return Bugsnag._client
                }
            Severity: Major
            Found in packages/browser/src/notifier.js and 2 other locations - About 1 hr to fix
            packages/node/src/notifier.js on lines 67..74
            packages/web-worker/src/notifier.js on lines 47..54

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

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

              start: (opts) => {
                if (Bugsnag._client) {
                  Bugsnag._client._logger.warn('Bugsnag.start() was called more than once. Ignoring.')
                  return Bugsnag._client
                }
            Severity: Major
            Found in packages/node/src/notifier.js and 2 other locations - About 1 hr to fix
            packages/browser/src/notifier.js on lines 78..85
            packages/web-worker/src/notifier.js on lines 47..54

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

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

              start: (opts) => {
                if (Bugsnag._client) {
                  Bugsnag._client._logger.warn('Bugsnag.start() was called more than once. Ignoring.')
                  return Bugsnag._client
                }
            Severity: Major
            Found in packages/web-worker/src/notifier.js and 2 other locations - About 1 hr to fix
            packages/browser/src/notifier.js on lines 78..85
            packages/node/src/notifier.js on lines 67..74

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

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

              load: (client) => {
                const emitter = new EventEmitter()
            
                // proxy all state updates from within the main process
                // so that we can emit events for the changes

            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 a Cognitive Complexity of 15 (exceeds 5 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

            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

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

                    req.bugsnag._notify(event, () => {}, (e, event) => {
                      if (e) client._logger.error('Failed to send event to Bugsnag')
                      req.bugsnag._config.onUncaughtException(err, event, client._logger)
                    })
            Severity: Major
            Found in packages/plugin-express/src/express.js and 1 other location - About 1 hr to fix
            packages/plugin-restify/src/restify.js on lines 38..41

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

            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

                    req.bugsnag._notify(event, () => {}, (e, event) => {
                      if (e) client._logger.error('Failed to send event to Bugsnag')
                      req.bugsnag._config.onUncaughtException(err, event, client._logger)
                    })
            Severity: Major
            Found in packages/plugin-restify/src/restify.js and 1 other location - About 1 hr to fix
            packages/plugin-express/src/express.js on lines 39..42

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

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

              load (client) {
                // load the actual session delegate from plugin-browser-session
                sessionDelegate.load(client)
            
                if (isNativeClientEnabled(client)) {
            Severity: Minor
            Found in packages/plugin-electron-session/session.js - About 1 hr to fix

              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
                          Severity
                          Category
                          Status
                          Source
                          Language