lipp/node-jet

View on GitHub

Showing 123 of 123 total issues

Function createDaemon has 283 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createDaemon = function (options) {
  options = options || {}
  const log = options.log || noop

  const users = options.users || {}
Severity: Major
Found in lib/jet/daemon.js - About 1 day to fix

    Function createDaemon has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
    Open

    const createDaemon = function (options) {
      options = options || {}
      const log = options.log || noop
    
      const users = options.users || {}
    Severity: Minor
    Found in lib/jet/daemon.js - About 1 day 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 57 (exceeds 5 allowed). Consider refactoring.
    Open

    exports.create = function (options, notify) {
      const matches = []
      const sorted = {}
      const index = {}
      let n = -1
    Severity: Minor
    Found in lib/jet/sorter.js - About 1 day 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 157 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.create = function (options, notify) {
      const matches = []
      const sorted = {}
      const index = {}
      let n = -1
    Severity: Major
    Found in lib/jet/sorter.js - About 6 hrs to fix

      Function sorter has 116 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        const sorter = function (notification, initializing) {
          const event = notification.event
          const path = notification.path
          const value = notification.value
          const lastMatchesLength = matches.length
      Severity: Major
      Found in lib/jet/sorter.js - About 4 hrs to fix

        Function createAsyncDispatcher has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

        State.prototype.createAsyncDispatcher = function (cb) {
          const that = this
        
          const dispatch = function (message) {
            const value = message.params.value
        Severity: Minor
        Found in lib/jet/peer/state.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

        File daemon.js has 317 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        'use strict'
        
        const net = require('./net')
        
        const uuid = require('uuid')
        Severity: Minor
        Found in lib/jet/daemon.js - About 3 hrs to fix

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

          State.prototype.on = function (event, cb) {
            if (event === 'set') {
              if (cb.length === 1) {
                this._dispatcher = this.createSyncDispatcher(cb)
              } else {
          Severity: Major
          Found in lib/jet/peer/state.js and 1 other location - About 3 hrs to fix
          lib/jet/peer/method.js on lines 20..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 103.

          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

          Method.prototype.on = function (event, cb) {
            if (event === 'call') {
              if (cb.length <= 1) {
                this._dispatcher = this.createSyncDispatcher(cb)
              } else {
          Severity: Major
          Found in lib/jet/peer/method.js and 1 other location - About 3 hrs to fix
          lib/jet/peer/state.js on lines 133..144

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

          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

              circle
                .transition()
                .duration(400)
                .ease('exp-out')
                .attr('r', ball.value.size)
          Severity: Major
          Found in examples/balls/balls-client.js and 1 other location - About 3 hrs to fix
          examples/balls/balls-client.js on lines 41..48

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

          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

              circle
                .transition()
                .duration(200)
                .ease('exp-out')
                .attr('r', ball.value.size)
          Severity: Major
          Found in examples/balls/balls-client.js and 1 other location - About 3 hrs to fix
          examples/balls/balls-client.js on lines 25..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 102.

          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

          Promise.all([
            peer.connect(),
            peer.add(addTodo),
            peer.add(removeTodo),
            peer.add(setCompleted),
          Severity: Major
          Found in examples/todo/todo-server.js and 1 other location - About 2 hrs to fix
          examples/balls/balls-server.js on lines 169..178

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

          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

          Promise.all([
            peer.connect(),
            peer.add(circle),
            peer.add(square),
            peer.add(boom),
          Severity: Major
          Found in examples/balls/balls-server.js and 1 other location - About 2 hrs to fix
          examples/todo/todo-server.js on lines 112..121

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

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

          exports.create = function (options, notify) {
            const pathMatcher = jetPathMatcher.create(options)
            const valueMatcher = jetValueMatcher.create(options)
            const added = {}
          
          
          Severity: Major
          Found in lib/jet/fetcher.js - About 2 hrs to fix

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

            const containsAllOf = function (whatArray) {
              return function (path) {
                let i
                for (i = 0; i < whatArray.length; i = i + 1) {
                  if (path.indexOf(whatArray[i]) === -1) {
            Severity: Major
            Found in lib/jet/path_matcher.js and 1 other location - About 2 hrs to fix
            lib/jet/path_matcher.js on lines 24..34

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

            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

            const containsOneOf = function (whatArray) {
              return function (path) {
                let i
                for (i = 0; i < whatArray.length; i = i + 1) {
                  if (path.indexOf(whatArray[i]) !== -1) {
            Severity: Major
            Found in lib/jet/path_matcher.js and 1 other location - About 2 hrs to fix
            lib/jet/path_matcher.js on lines 12..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 89.

            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

            var randomColor = function () {
              var hue = Math.abs(Math.random()) * 360
              var saturation = 40 + Math.abs(Math.random()) * 60
              return 'hsl(' + hue + ',' + saturation + '%,60%)'
            }
            Severity: Major
            Found in examples/balls/balls-client.js and 1 other location - About 2 hrs to fix
            examples/balls/balls-server.js on lines 90..94

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

            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

            var randomColor = function () {
              var hue = Math.abs(Math.random()) * 360
              var saturation = 40 + Math.abs(Math.random()) * 60
              return 'hsl(' + hue + ',' + saturation + '%,60%)'
            }
            Severity: Major
            Found in examples/balls/balls-server.js and 1 other location - About 2 hrs to fix
            examples/balls/balls-client.js on lines 13..17

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

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

            exports.Peers = function (jsonrpc, elements) {
              const instances = {}
            
              const remove = function (peer) {
                if (peer && instances[peer.id]) {
            Severity: Major
            Found in lib/jet/daemon/peers.js - About 2 hrs to fix

              Function listen has 59 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                daemon.listen = function (listenOptions) {
                  const defaultListenOptions = {
                    tcpPort: 11122,
                    wsPort: 11123
                  }
              Severity: Major
              Found in lib/jet/daemon.js - About 2 hrs to fix
                Severity
                Category
                Status
                Source
                Language