gmmorris/birdwatcherjs

View on GitHub

Showing 8 of 8 total issues

Function birdwatcher has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

export default function birdwatcher(watchedComponent, name = '', configuration = defaultConfiguration) {
  if (typeof name === 'object') {
    configuration = name;
    name = '';
  }
Severity: Minor
Found in src/birdwatcher.js - About 4 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 birdwatcher has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function birdwatcher(watchedComponent, name = '', configuration = defaultConfiguration) {
  if (typeof name === 'object') {
    configuration = name;
    name = '';
  }
Severity: Minor
Found in src/birdwatcher.js - About 1 hr to fix

    Function default has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export default function(birdwatcheredObj, name, methodName, method, configuration, birdwatcherObject) {
      return function() {
        try {
          return method.apply(this, arguments);
        } catch (o_O) {
    Severity: Minor
    Found in src/createErrorClosure.js - About 1 hr to fix

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

      export default function configure(birdwatcherOverride, nameOverride, configurationOverride) {
        if (!isBirdwatcher(birdwatcherOverride)) {
          configurationOverride = nameOverride;
          nameOverride = birdwatcherOverride;
          birdwatcherOverride = false;
      Severity: Minor
      Found in src/configure.js - About 1 hr to fix

        Avoid deeply nested control flow statements.
        Open

                  if (isWatchablePropertyOfComponent(watchedComponent, prop)) {
                    /**
                     * Create a cloure which will be called instead of the existing method on the birdwatchered object.
                     * Usually it will simply add a call for the method and return it's value, as usual.
                     * This is a completly covert operation... the object being birdwatchered doesn't even know
        Severity: Major
        Found in src/birdwatcher.js - About 45 mins to fix

          Function default has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          export default function(birdwatcheredObj, name, methodName, method, configuration, birdwatcherObject) {
          Severity: Minor
          Found in src/createErrorClosure.js - About 45 mins to fix

            Function pick has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export default function pick(source, ...keys) {
              const pickedObject = {};
              if (typeof source === 'object') {
                while (keys.length) {
                  const key = keys.pop();
            Severity: Minor
            Found in src/tools/pick.js - About 25 mins 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 isWatchablePropertyOfConstructor has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

            export function isWatchablePropertyOfConstructor(WatchedClass, methodName) {
              if (!WatchedClass || !methodName) {
                return false;
              }
            
            
            Severity: Minor
            Found in src/tools/isWatchableProperty.js - About 25 mins 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