bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

Function _redeliver has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async _redeliver () {
    try {
      if (this._sending) {
        return
      }
Severity: Minor
Found in packages/delivery-electron/payload-loop.js - About 1 hr to fix

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

      load: client => {
        client.addOnError(async (event) => {
          const {
            app,
            breadcrumbs,
    Severity: Minor
    Found in packages/plugin-electron-renderer-event-data/renderer-event-data.js - About 1 hr to fix

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

            clientStateManager.emitter.on('ContextUpdate', context => {
              try {
                NativeClient.updateContext(context)
              } catch (e) {
                client._logger.error(e)
      packages/plugin-electron-client-state-persistence/client-state-persistence.js on lines 47..53

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

      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

            clientStateManager.emitter.on('MetadataReplace', (metadata) => {
              try {
                NativeClient.updateMetadata(metadata)
              } catch (e) {
                client._logger.error(e)
      packages/plugin-electron-client-state-persistence/client-state-persistence.js on lines 31..37

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

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

        constructor (configuration, schema = config.schema, internalPlugins = [], notifier) {
          // notifier id
          this._notifier = notifier
      
          // intialise opts and config
      Severity: Minor
      Found in packages/core/client.js - About 1 hr to fix

        Function visit has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          const visit = (obj) => {
            if (obj === null || obj === undefined) return obj
        
            if (isSafeLiteral(obj)) {
              return obj
        Severity: Minor
        Found in packages/core/lib/derecursify.js - About 1 hr to fix

          Function send has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            const send = (opts, body, cb) => {
              let errorCallback = (error, response) => {
                // an error can still happen on both the request and response even after a response is received,
                // so we noop on subsequent calls to ensure this is only handled once
                errorCallback = noop
          Severity: Minor
          Found in packages/delivery-electron/delivery.js - About 1 hr to fix

            Function addBuildEndpoint has 33 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function addBuildEndpoint (projectRoot: string, buildEndpoint: string, logger: Logger): Promise<void> {
              try {
                const appBuildGradlePath = path.join(projectRoot, 'android', 'app', 'build.gradle')
            
                await insertBugsnagConfigBlock(appBuildGradlePath, logger)
            Severity: Minor
            Found in packages/react-native-cli/src/lib/Gradle.ts - About 1 hr to fix

              Function addUploadEndpoint has 33 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export async function addUploadEndpoint (projectRoot: string, uploadEndpoint: string, logger: Logger): Promise<void> {
                try {
                  const appBuildGradlePath = path.join(projectRoot, 'android', 'app', 'build.gradle')
              
                  await insertBugsnagConfigBlock(appBuildGradlePath, logger)
              Severity: Minor
              Found in packages/react-native-cli/src/lib/Gradle.ts - About 1 hr to fix

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

                      if (event.unhandled !== event._handledState.unhandled) {
                        event._handledState.severityReason.unhandledOverridden = true
                        event._handledState.unhandled = event.unhandled
                      }
                Severity: Major
                Found in packages/core/client.js and 1 other location - About 1 hr to fix
                packages/plugin-electron-ipc/bugsnag-ipc-main.js on lines 77..80

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

                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 (process.env.NODE_ENV !== 'production') {
                  exports.destroy = (win = window) => {
                    win.history.replaceState._restore()
                    win.history.pushState._restore()
                  }
                packages/plugin-navigation-breadcrumbs/navigation-breadcrumbs.js on lines 36..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 61.

                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

                      if (event.unhandled !== event._handledState.unhandled) {
                        event._handledState.severityReason.unhandledOverridden = true
                        event._handledState.unhandled = event.unhandled
                      }
                Severity: Major
                Found in packages/plugin-electron-ipc/bugsnag-ipc-main.js and 1 other location - About 1 hr to fix
                packages/core/client.js on lines 340..343

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

                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 (process.env.NODE_ENV !== 'production') {
                    plugin.destroy = (win = window) => {
                      win.history.replaceState._restore()
                      win.history.pushState._restore()
                    }
                packages/plugin-navigation-breadcrumbs/navigation-breadcrumbs.js on lines 46..51

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

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

                  _dispatch (event) {
                    const originalSeverity = event.severity
                
                    const callbacks = this.client._cbs.e.filter(e => !e._internal)
                    runCallbacks(callbacks, event, this._onCallbackError, (err, shouldSend) => {
                Severity: Minor
                Found in packages/plugin-electron-ipc/bugsnag-ipc-main.js - About 1 hr to fix

                  Function createNavigationContainer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      const createNavigationContainer = (NavigationContainer) => React.forwardRef((props, ref) => {
                        const { onReady, onStateChange, ...forwardProps } = props
                        const navigationRef = ref || React.useRef(null)
                        const routeNameRef = React.useRef(undefined)
                  
                  
                  Severity: Minor
                  Found in packages/plugin-react-navigation/react-navigation.js - About 1 hr to fix

                    Function exports has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = (nav = navigator, win = window) => ({
                      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

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

                    Event.create = function (maybeError, tolerateNonErrors, handledState, component, errorFramesToSkip = 0, logger) {
                      const [error, internalFrames] = normaliseError(maybeError, tolerateNonErrors, component, logger)
                      let event
                      try {
                        const stacktrace = Event.getStacktrace(
                    Severity: Minor
                    Found in packages/core/event.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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                      load: client => {
                        if (!client._config.sendCode) return
                    
                        const loadSurroundingCode = (stackframe, cache) => new Promise((resolve, reject) => {
                          try {
                    Severity: Minor
                    Found in packages/plugin-node-surrounding-code/surrounding-code.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 getNodeSelector has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function getNodeSelector (el, win) {
                      const parts = [el.tagName]
                      if (el.id) parts.push('#' + el.id)
                      if (el.className && el.className.length) parts.push(`.${el.className.split(' ').join('.')}`)
                      // Can't get much more advanced with the current browser
                    Severity: Minor
                    Found in packages/plugin-interaction-breadcrumbs/interaction-breadcrumbs.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 makeBrowserWindow has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                    export function makeBrowserWindow ({ windows = [], focusedWindow = null } = {}): BrowserWindowStatic {
                      const FakeBrowserWindow: BrowserWindowStatic = class implements BrowserWindow {
                        public index: number
                    
                        public readonly title: string
                    Severity: Minor
                    Found in packages/electron-test-helpers/src/BrowserWindow.ts - 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