bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

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

export async function install (projectRoot: string, logger: Logger): Promise<void> {
  if (platform() !== 'darwin') {
    logger.warn('Detected platform is not macOS, skipping')
    return
  }
Severity: Minor
Found in packages/react-native-cli/src/lib/Pod.ts - About 1 hr to fix

    Method toWritableArray has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      static WritableArray toWritableArray(Collection<? extends Object> collection) {
        WritableArray writableArray = Arguments.createArray();
    
        if (collection == null) {
          return writableArray;

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

    module.exports = (BugsnagIpcRenderer = window.__bugsnag_ipc__) => ({
      load: (client) => {
        client.addOnBreadcrumb(breadcrumb => {
          try {
            BugsnagIpcRenderer.leaveBreadcrumb(Object.assign({}, breadcrumb))

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

    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

    Method toWritableMap has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      @SuppressWarnings("unchecked")
      static WritableMap toWritableMap(Map<String, ? extends Object> javaMap) {
        WritableMap writableMap = Arguments.createMap();
    
        if (javaMap == null) {

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

    const formatComponentName = (vm, includeFile) => {
      if (vm.$root === vm) return '<Root>'
      const options = typeof vm === 'function' && vm.cid != null
        ? vm.options
        : vm._isVue
    Severity: Minor
    Found in packages/plugin-vue/src/vue2.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 mergeOptions has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports.mergeOptions = (additionalSchemaKeys, mainOpts, rendererOpts) => {
      return Object.keys(module.exports.schema).concat(additionalSchemaKeys).reduce((accum, k) => {
        if (Object.prototype.hasOwnProperty.call(rendererOpts, k)) {
          if (ALLOWED_IN_RENDERER.includes(k)) {
            if (k === 'metadata') {
    Severity: Minor
    Found in packages/electron/src/config/renderer.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = (NativeClient) => ({
      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
    Severity: Minor
    Found in packages/plugin-react-native-client-sync/client-sync.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 10 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = ctx => {
      if (!ctx) return {}
      const request = ctx.req
      const connection = request.connection
      const address = connection && connection.address && connection.address()
    Severity: Minor
    Found in packages/plugin-koa/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 load has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      load: (client) => {
        const device = {
          locale: nav.browserLanguage || nav.systemLanguage || nav.userLanguage || nav.language,
          userAgent: nav.userAgent
        }
    Severity: Minor
    Found in packages/plugin-browser-device/device.js - About 1 hr to fix

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

      module.exports = (win = window) => {
        const plugin = {
          load: (client) => {
            if (!('addEventListener' in win)) return
            if (!client._isBreadcrumbTypeEnabled('navigation')) return
      Severity: Minor
      Found in packages/plugin-navigation-breadcrumbs/navigation-breadcrumbs.js - About 1 hr to fix

        Function listener has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              const listener = evt => {
                let error = evt.reason
                let isBluebird = false
        
                // accessing properties on evt.detail can throw errors (see #394)
        Severity: Minor
        Found in packages/plugin-window-unhandled-rejection/unhandled-rejection.js - About 1 hr to fix

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

            load: (client) => {
              const sessionTracker = new SessionTracker(client._config.sessionSummaryInterval)
              sessionTracker.on('summary', sendSessionSummary(client))
              sessionTracker.start()
              client._sessionDelegate = {
          Severity: Minor
          Found in packages/plugin-server-session/session.js - About 1 hr to fix

            Function sendMinidump has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              const sendMinidump = async (minidumpPath, event) => {
                const apiKey = (event && event.apiKey) || client._config.apiKey
                const url = new URL(client._config.endpoints.minidumps)
                url.pathname = `${url.pathname.replace(/\/$/, '')}/minidump`
                url.searchParams.set('api_key', apiKey)
            Severity: Minor
            Found in packages/plugin-electron-deliver-minidumps/send-minidump.js - About 1 hr to fix

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

              export default async function run (projectRoot: string, urls: OnPremiseUrls): Promise<boolean> {
                try {
                  const { apiKey } = await prompts({
                    type: 'text',
                    name: 'apiKey',
              Severity: Minor
              Found in packages/react-native-cli/src/commands/ConfigureCommand.ts - About 1 hr to fix

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

                      if (req.bugsnag) {
                        req.bugsnag._notify(event)
                      } else {
                        client._logger.warn(
                          'req.bugsnag is not defined. Make sure the @bugsnag/plugin-express requestHandler middleware is added first.'
                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 64..71

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

                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

                      screen.on('display-removed', (_event, display) => {
                        const metadata = anonymise(display)
                
                        client.leaveBreadcrumb(
                          `Display ${metadata.id} removed`,
                packages/plugin-electron-screen-breadcrumbs/screen-breadcrumbs.js on lines 22..30

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

                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

                      screen.on('display-added', (_event, display) => {
                        const metadata = anonymise(display)
                
                        client.leaveBreadcrumb(
                          `Display ${metadata.id} added`,
                packages/plugin-electron-screen-breadcrumbs/screen-breadcrumbs.js on lines 32..40

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

                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

                      if (req.bugsnag) {
                        req.bugsnag._notify(event)
                      } else {
                        client._logger.warn(
                          'req.bugsnag is not defined. Make sure the @bugsnag/plugin-restify requestHandler middleware is added first.'
                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 61..68

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

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

                const _createClient = (opts, jsOpts) => {
                  if (jsOpts && typeof jsOpts === 'object') {
                    // mutate the options with anything supplied in JS. This will throw
                    Object.keys(jsOpts).forEach(k => { opts[k] = jsOpts[k] })
                  }
                Severity: Minor
                Found in packages/react-native/src/notifier.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language