bugsnag/bugsnag-js

View on GitHub

Showing 343 of 352 total issues

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

      onUnhandled: (id, error) => {
        const event = client.Event.create(error, false, {
          severity: 'error',
          unhandled: true,
          severityReason: { type: 'unhandledPromiseRejection' }
packages/plugin-react-native-unhandled-rejection/rejection-handler.js on lines 19..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 86.

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

      resumeSession: (client) => {
        // Do nothing if there's already an active session
        if (client._session) {
          return client
        }
Severity: Major
Found in packages/plugin-server-session/session.js and 1 other location - About 2 hrs to fix
packages/plugin-browser-session/session.js on lines 33..49

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

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

  resumeSession: (client) => {
    // Do nothing if there's already an active session
    if (client._session) {
      return client
    }
Severity: Major
Found in packages/plugin-browser-session/session.js and 1 other location - About 2 hrs to fix
packages/plugin-server-session/session.js on lines 24..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 85.

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

File client.js has 270 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const config = require('./config')
const Event = require('./event')
const Breadcrumb = require('./breadcrumb')
const Session = require('./session')
const map = require('./lib/es-utils/map')
Severity: Minor
Found in packages/core/client.js - About 2 hrs to fix

    Function configure has a Cognitive Complexity of 18 (exceeds 5 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 2 hrs 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

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

      featureFlags: {
        defaultValue: () => [],
        message: 'should be an array of objects that have a "name" property',
        validate: value =>
          isArray(value) && value.length === filter(value, feature =>
    Severity: Major
    Found in packages/core/config.js and 1 other location - About 2 hrs to fix
    packages/core/config.js on lines 149..156

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

    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

      plugins: {
        defaultValue: () => ([]),
        message: 'should be an array of plugin objects',
        validate: value =>
          isArray(value) && value.length === filter(value, p =>
    Severity: Major
    Found in packages/core/config.js and 1 other location - About 2 hrs to fix
    packages/core/config.js on lines 157..164

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

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

    function wrapHandler (client, flushTimeoutMs, lambdaTimeoutNotifyMs, handler) {
      let _handler = handler
    
      if (handler.length > 2) {
        // This is a handler expecting a 'callback' argument, so we convert
    Severity: Major
    Found in packages/plugin-aws-lambda/src/index.js - About 2 hrs to fix

      Function run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      export default async function run (argv: string[]): Promise<void> {
        try {
          const opts = commandLineArgs(topLevelDefs, { argv, stopAtFirstUnknown: true })
      
          if (opts.version) {
      Severity: Minor
      Found in packages/react-native-cli/src/bin/cli.ts - About 2 hrs 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 normaliseError has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const normaliseError = (maybeError, tolerateNonErrors, component, logger) => {
        let error
        let internalFrames = 0
      
        const createAndLogInputError = (reason) => {
      Severity: Major
      Found in packages/core/event.js - About 2 hrs to fix

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

        export default async function run (argv: string[]): Promise<void> {
          try {
            const opts = commandLineArgs(topLevelDefs, { argv, stopAtFirstUnknown: true })
        
            if (opts.version) {
        Severity: Major
        Found in packages/react-native-cli/src/bin/cli.ts - About 2 hrs to fix

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

          module.exports = (win = window) => {
            const plugin = {
              load: (client) => {
                if (!client._config.autoDetectErrors || !client._config.enabledErrorTypes.unhandledRejections) return
                const listener = evt => {
          Severity: Major
          Found in packages/plugin-window-unhandled-rejection/unhandled-rejection.js - About 2 hrs to fix

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

            const getPrefixedConsole = () => {
              return ['debug', 'info', 'warn', 'error'].reduce((accum, method) => {
                const consoleMethod = console[method] || console.log
                accum[method] = consoleMethod.bind(console, '[bugsnag][main]')
                return accum
            Severity: Major
            Found in packages/electron/src/config/main.js and 3 other locations - About 2 hrs to fix
            packages/electron/src/config/common.js on lines 52..58
            packages/electron/src/config/renderer.js on lines 48..54
            packages/node/src/config.js on lines 53..59

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

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

            const getPrefixedConsole = () => {
              return ['debug', 'info', 'warn', 'error'].reduce((accum, method) => {
                const consoleMethod = console[method] || console.log
                accum[method] = consoleMethod.bind(console, '[bugsnag][main]')
                return accum
            Severity: Major
            Found in packages/electron/src/config/common.js and 3 other locations - About 2 hrs to fix
            packages/electron/src/config/main.js on lines 46..52
            packages/electron/src/config/renderer.js on lines 48..54
            packages/node/src/config.js on lines 53..59

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

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

            const getPrefixedConsole = () => {
              return ['debug', 'info', 'warn', 'error'].reduce((accum, method) => {
                const consoleMethod = console[method] || console.log
                accum[method] = consoleMethod.bind(console, '[bugsnag]')
                return accum
            Severity: Major
            Found in packages/node/src/config.js and 3 other locations - About 2 hrs to fix
            packages/electron/src/config/common.js on lines 52..58
            packages/electron/src/config/main.js on lines 46..52
            packages/electron/src/config/renderer.js on lines 48..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 79.

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

            const getPrefixedConsole = () => {
              return ['debug', 'info', 'warn', 'error'].reduce((accum, method) => {
                const consoleMethod = console[method] || console.log
                accum[method] = consoleMethod.bind(console, '[bugsnag]')
                return accum
            Severity: Major
            Found in packages/electron/src/config/renderer.js and 3 other locations - About 2 hrs to fix
            packages/electron/src/config/common.js on lines 52..58
            packages/electron/src/config/main.js on lines 46..52
            packages/node/src/config.js on lines 53..59

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

            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

            BugsnagReactNative has 21 methods (exceeds 20 allowed). Consider refactoring.
            Open

            public class BugsnagReactNative extends ReactContextBaseJavaModule {
            
              private final BugsnagReactNativeImpl impl;
            
              public BugsnagReactNative(ReactApplicationContext reactContext) {

              NativeBugsnagImpl has 21 methods (exceeds 20 allowed). Consider refactoring.
              Open

              public class NativeBugsnagImpl extends NativeBugsnagSpec {
                private final BugsnagReactNativeImpl impl;
              
                public NativeBugsnagImpl(ReactApplicationContext reactContext) {
                  super(reactContext);

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

                      requestClient.addOnError((event) => {
                        const { metadata, request } = getRequestAndMetadataFromReq(req)
                        event.request = { ...event.request, ...request }
                        event.addMetadata('request', metadata)
                      }, true)
                Severity: Major
                Found in packages/plugin-express/src/express.js and 2 other locations - About 2 hrs to fix
                packages/plugin-koa/src/koa.js on lines 24..28
                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

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

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

                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

                Severity
                Category
                Status
                Source
                Language