Showing 316 of 336 total issues

Method validate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def self.validate(model, field_name, args)
      errors = {}
      value  = model.get(field_name)
      if !value || value.blank?
        if args.is_a?(Hash) && args[:message]
Severity: Minor
Found in lib/volt/models/validators/presence_validator.rb - 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

Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize(app, options = {})
      @app = app
      @options = Volt.config.http_content_types ? Volt.config.http_content_types.dup : {}
      @options.merge!(options)
      @parsers = @options[:parsers] || {}
Severity: Minor
Found in lib/volt/server/rack/http_content_types.rb - 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

Method assign_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def assign_attributes(attrs, initial_setup = false, skip_changes = false)
      attrs = wrap_values(attrs)

      if attrs
        # When doing a mass-assign, we don't validate or save until the end.
Severity: Minor
Found in lib/volt/models/model.rb - 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

Method read_new_model has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def read_new_model(method_name)
      if @persistor && @persistor.respond_to?(:read_new_model)
        return @persistor.read_new_model(method_name)
      else
        opts = @options.merge(parent: self, path: path + [method_name])
Severity: Minor
Found in lib/volt/models/model.rb - 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

Method delete has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def delete(val)
      # Check to make sure the models are allowed to be deleted
      if !val.is_a?(Model)
        # Not a model, return as a Promise
        super(val).then
Severity: Minor
Found in lib/volt/models/array_model.rb - 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

Method setup_port_ranges has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def setup_port_ranges
          port_ranges = Volt.config.message_bus.try(:bind_port_ranges)

          if port_ranges
            # Expand any ranges, then sample one from the array
Severity: Minor
Found in lib/volt/server/message_bus/peer_to_peer/peer_server.rb - 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

Method nested_params_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def nested_params_hash(params, path = [])
      results = {}

      params.each_pair do |key, value|
        unless value.nil?
Severity: Minor
Found in lib/volt/models/url.rb - 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

Method on has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def on(*events, &callback)
      fail '.on requires an event' if events.size == 0

      listener = Listener.new(self, events, callback)

Severity: Minor
Found in lib/volt/reactive/eventable.rb - 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

Method remove_duplicate_connections has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def remove_duplicate_connections
        peer_server_ids = {}

        # remove any we are connected to twice
        @peer_connections.keys.each do |peer|
Severity: Minor
Found in lib/volt/server/message_bus/peer_to_peer.rb - 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

Method fetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def fetch(&block)
        Volt.logger.warn('Deprication warning: in 0.9.3.pre4, all query methods on store now return Promises, so you can juse use .all or .first instead of .fetch')
        promise = Promise.new

        # Run the block after resolve if a block is passed in
Severity: Minor
Found in lib/volt/models/persistors/array_store.rb - 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

Method write_cookie has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def write_cookie(key, value, options = {})
        options[:path] ||= '/'
        parts = []

        parts << `encodeURIComponent(key)`
Severity: Minor
Found in lib/volt/models/persistors/cookies.rb - 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

Method release_write_lock has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def release_write_lock
    loop do
      c = @counter.value
      if @counter.compare_and_swap(c, c - RUNNING_WRITER)
        @reader_mutex.synchronize { @reader_q.broadcast }
Severity: Minor
Found in lib/volt/utils/read_write_lock.rb - 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

Method load_stored_page has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def load_stored_page
      if Volt.client?
        if `sessionStorage`
          page = Volt.current_app.page
          page_obj_str = nil
Severity: Minor
Found in lib/volt/volt/client_setup/browser.rb - 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

Method copy_options has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def copy_options
    if @options[:coc] or yes?("\nDo you want to include a code of conduct in this gem?\n\n\
Codes of conduct can increase contributions to your project by contributors who \
prefer collaborative, safe spaces. You can read more about the code of conduct at \
contributor-covenant.org. Having a code of conduct means agreeing to the responsibility \
Severity: Minor
Found in lib/volt/cli/new_gem.rb - 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

Method initialize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def initialize
      # Use VOLT_ENV or RACK_ENV to set the environment
      @env = ENV['VOLT_ENV'] || ENV['RACK_ENV']

      # If we're in opal, we can set the env from JS before opal loads
Severity: Minor
Found in lib/volt/volt/environment.rb - 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

Method link_clicked has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def link_clicked(url = '', event = nil)
      target = nil
      `target = $(event.target).attr('target');`
      `if (!target) {`
        `target = #{nil};`
Severity: Minor
Found in lib/volt/volt/client_setup/browser.rb - 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