bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

Function getSuggestedBugsnagGradleVersion has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

export async function getSuggestedBugsnagGradleVersion (projectRoot: string, logger: Logger): Promise<string> {
  let fileContents: string
  try {
    fileContents = await fs.readFile(path.join(projectRoot, 'android', 'build.gradle'), 'utf8')
  } catch (e) {
Severity: Minor
Found in packages/react-native-cli/src/lib/Gradle.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

Function _configure has 39 lines of code (exceeds 25 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

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

      onUncaughtException: {
        defaultValue: () => (err, event, logger) => {
          logger.error(`Uncaught exception…\n${printError(err)}`)
        },
        message: 'should be a function',
    Severity: Major
    Found in packages/electron/src/config/main.js and 1 other location - About 1 hr to fix
    packages/electron/src/config/main.js on lines 26..32

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

    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

      onUnhandledRejection: {
        defaultValue: () => (err, event, logger) => {
          logger.error(`Unhandled rejection…\n${printError(err)}`)
        },
        message: 'should be a function',
    Severity: Major
    Found in packages/electron/src/config/main.js and 1 other location - About 1 hr to fix
    packages/electron/src/config/main.js on lines 19..25

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

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

      buildAndroid: function buildAndroid (sourceFixturesIn, destFixturesIn) {
        try {
          const baseDir = process.env.PWD
          const sourceFixtures = `${baseDir}/${sourceFixturesIn}`
          const destFixtures = `${baseDir}/${destFixturesIn}`
    Severity: Minor
    Found in scripts/react-native-cli-helper.js - About 1 hr to fix

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

        load: (client) => {
          if (!isEnabledFor(client)) {
            return
          }
      
      
      Severity: Minor
      Found in packages/plugin-electron-deliver-minidumps/deliver-minidumps.js - About 1 hr to fix

        Function sendSessionSummary has 38 lines of code (exceeds 25 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

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

              load: (client) => {
                if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes.unhandledRejections) return
                const listener = evt => {
                  let error = evt.reason
                  let isBluebird = false
          Severity: Minor
          Found in packages/plugin-window-unhandled-rejection/unhandled-rejection.js - About 1 hr to fix

            Function insertAndroid has 38 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export async function insertAndroid (projectRoot: string, logger: Logger): Promise<void> {
              logger.info('Adding Bugsnag to the Android layer')
            
              let mainApplicationPath
              try {
            Severity: Minor
            Found in packages/react-native-cli/src/lib/Insert.ts - About 1 hr to fix

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

              module.exports = api => {
                // NB: This function can be called without an api argument, e.g. by bin/bundle
              
                const presets = []
                const plugins = []
              Severity: Minor
              Found in babel.config.js - About 1 hr to fix

                Function createClient has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                const createClient = (createProcessClient, process) => {
                  const Bugsnag = {
                    _client: null,
                    lastRunInfo: null,
                    start: (opts) => {
                Severity: Minor
                Found in packages/electron/src/client/createClient.js - About 1 hr to fix

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

                  module.exports = function (data) {
                    const seen = []
                  
                    const visit = (obj) => {
                      if (obj === null || obj === undefined) return obj
                  Severity: Minor
                  Found in packages/core/lib/derecursify.js - About 1 hr to fix

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

                    module.exports = (NativeClient, process, electronApp, BrowserWindow, filestore, NativeApp = native) => ({
                      name: 'electronApp',
                      load (client) {
                        const app = {}
                        const lastRunInfo = filestore.getLastRunInfo()
                    Severity: Minor
                    Found in packages/plugin-electron-app/app.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 12 (exceeds 5 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: Minor
                    Found in packages/plugin-electron-deliver-minidumps/send-minidump.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 12 (exceeds 5 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

                    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 deserialiseEvent has a Cognitive Complexity of 12 (exceeds 5 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

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

                      start: (opts) => {
                        if (Bugsnag._client) {
                          Bugsnag._client._logger.warn('Bugsnag.start() was called more than once. Ignoring.')
                          return Bugsnag._client
                        }
                    Severity: Minor
                    Found in packages/react-native/src/notifier.js - About 1 hr to fix

                      Function writeToPackageJson has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function writeToPackageJson (packageJsonPath: string, uploadUrl?: string, buildUrl?: string): Promise<void> {
                        try {
                          const data = await fs.readFile(packageJsonPath, 'utf8')
                          const packageJson = JSON.parse(data)
                      
                      

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

                        jest.mock('fs', () => {
                          return { promises: { readFile: jest.fn(), writeFile: jest.fn(), readdir: jest.fn() } }
                        })
                        packages/react-native-cli/src/lib/__test__/Insert.test.ts on lines 20..22

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

                        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

                        jest.mock('fs', () => {
                          return { promises: { readFile: jest.fn(), writeFile: jest.fn(), readdir: jest.fn() } }
                        })
                        Severity: Major
                        Found in packages/react-native-cli/src/lib/__test__/Insert.test.ts and 1 other location - About 1 hr to fix
                        packages/react-native-cli/src/lib/__test__/InfoPlist.test.ts on lines 19..21

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

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language