ruby-druid/ruby-druid

View on GitHub

Showing 32 of 32 total issues

File query.rb has 431 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'time'
require 'iso8601'

require 'active_support/all'
require 'active_model'
Severity: Minor
Found in lib/druid/query.rb - About 6 hrs to fix

    File filter.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Druid
      class Filter
        include ActiveModel::Model
    
        attr_accessor :type
    Severity: Minor
    Found in lib/druid/filter.rb - About 3 hrs to fix

      Class Builder has 26 methods (exceeds 20 allowed). Consider refactoring.
      Open

          class Builder
      
            attr_reader :query
      
            def initialize
      Severity: Minor
      Found in lib/druid/query.rb - About 3 hrs to fix

        Method validate_each has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
        Open

              def validate_each(record, attribute, value)
                if !value.is_a?(Array) || value.blank?
                  record.errors.add(attribute, 'must be a list with at least one interval')
                  return
                end
        Severity: Minor
        Found in lib/druid/query.rb - 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

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

              def validate_each(record, attribute, value)
                if TYPES.include?(record.queryType)
                  if !value.is_a?(Array) || value.blank?
                    record.errors.add(attribute, 'must be a list with at least one dimension')
                  else
        Severity: Major
        Found in lib/druid/query.rb and 1 other location - About 1 hr to fix
        lib/druid/query.rb on lines 121..134

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

        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

              def validate_each(record, attribute, value)
                if TYPES.include?(record.queryType)
                  if !value.is_a?(Array) || value.blank?
                    record.errors.add(attribute, 'must be a list with at least one aggregator')
                  else
        Severity: Major
        Found in lib/druid/query.rb and 1 other location - About 1 hr to fix
        lib/druid/query.rb on lines 82..95

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

        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

        Method validate_each has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

              def validate_each(record, attribute, value)
                if TYPES.include?(record.queryType)
                  if value.is_a?(String)
                    record.errors.add(attribute, "must be one of #{SIMPLE.inspect}") unless SIMPLE.include?(value)
                  elsif value.is_a?(Granularity)
        Severity: Minor
        Found in lib/druid/query.rb - 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

        Method dimensions= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def dimensions=(value)
              if value.is_a?(Array)
                @dimensions = value.map do |x|
                  x.is_a?(Dimension) ? x : Dimension.new(x)
                end
        Severity: Minor
        Found in lib/druid/query.rb - About 55 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 aggregations= has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            def aggregations=(value)
              if value.is_a?(Array)
                @aggregations = value.map do |x|
                  x.is_a?(Aggregation) ? x : Aggregation.new(x)
                end
        Severity: Minor
        Found in lib/druid/query.rb - About 55 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 metadata! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def metadata!(opts = {})
              meta_path = "#{@uri.path}datasources/#{name}"
        
              if opts[:interval]
                from, to = opts[:interval]
        Severity: Minor
        Found in lib/druid/data_source.rb - About 45 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

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

              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  value.each(&:valid?) # trigger validation
                  value.each do |fvalue|
                    fvalue.errors.messages.each do |k, v|
        Severity: Minor
        Found in lib/druid/post_aggregation.rb and 1 other location - About 45 mins to fix
        lib/druid/having.rb on lines 10..19

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

        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

              def validate_each(record, attribute, value)
                if TYPES.include?(record.queryType)
                  value.each(&:valid?) # trigger validation
                  value.each do |avalue|
                    avalue.errors.messages.each do |k, v|
        Severity: Minor
        Found in lib/druid/having.rb and 1 other location - About 45 mins to fix
        lib/druid/post_aggregation.rb on lines 38..47

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

        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

        Method verify_broker has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def verify_broker(service, name)
              $log.debug("druid.zk verify", broker: name, service: service) if $log
              info = @zk.get("#{watch_path(service)}/#{name}")
              node = MultiJson.load(info[0])
              uri = "http://#{node['address']}:#{node['port']}/druid/v2/"
        Severity: Minor
        Found in lib/druid/zk.rb - About 35 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

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

            class AggregationValidator < ActiveModel::EachValidator
              TYPES = %w(greaterThan lessThan equalTo)
              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  record.errors.add(attribute, 'may not be blank') if value.blank?
        Severity: Minor
        Found in lib/druid/having.rb and 1 other location - About 30 mins to fix
        lib/druid/filter.rb on lines 8..14

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

        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

            class DimensionValidator < ActiveModel::EachValidator
              TYPES = %w(selector regex javascript)
              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  record.errors.add(attribute, 'may not be blank') if value.blank?
        Severity: Minor
        Found in lib/druid/filter.rb and 1 other location - About 30 mins to fix
        lib/druid/having.rb on lines 45..51

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

        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

            class AggregatorValidator < ActiveModel::EachValidator
              TYPES = %w[filtered].freeze
              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  record.errors.add(attribute, 'may not be blank') if value.blank?
        Severity: Minor
        Found in lib/druid/aggregation.rb and 1 other location - About 30 mins to fix
        lib/druid/aggregation.rb on lines 62..68

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

        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

            class FilterValidator < ActiveModel::EachValidator
              TYPES = %w[filtered].freeze
              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  record.errors.add(attribute, 'may not be blank') if value.blank?
        Severity: Minor
        Found in lib/druid/aggregation.rb and 1 other location - About 30 mins to fix
        lib/druid/aggregation.rb on lines 76..82

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

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

            class ValueValidator < ActiveModel::EachValidator
              TYPES = %w(selector)
              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  record.errors.add(attribute, 'may not be blank') if value.blank?
        Severity: Major
        Found in lib/druid/filter.rb and 6 other locations - About 25 mins to fix
        lib/druid/aggregation.rb on lines 39..45
        lib/druid/dimension.rb on lines 14..20
        lib/druid/filter.rb on lines 36..42
        lib/druid/filter.rb on lines 112..118
        lib/druid/having.rb on lines 31..37
        lib/druid/post_aggregation.rb on lines 89..95

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

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

            class FunctionValidator < ActiveModel::EachValidator
              TYPES = %w(javascript)
              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  record.errors.add(attribute, 'may not be blank') if value.blank?
        Severity: Major
        Found in lib/druid/filter.rb and 6 other locations - About 25 mins to fix
        lib/druid/aggregation.rb on lines 39..45
        lib/druid/dimension.rb on lines 14..20
        lib/druid/filter.rb on lines 22..28
        lib/druid/filter.rb on lines 36..42
        lib/druid/having.rb on lines 31..37
        lib/druid/post_aggregation.rb on lines 89..95

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

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

            class FunctionValidator < ActiveModel::EachValidator
              TYPES = %w(javascript)
              def validate_each(record, attribute, value)
                if TYPES.include?(record.type)
                  record.errors.add(attribute, 'may not be blank') if value.blank?
        Severity: Major
        Found in lib/druid/post_aggregation.rb and 6 other locations - About 25 mins to fix
        lib/druid/aggregation.rb on lines 39..45
        lib/druid/dimension.rb on lines 14..20
        lib/druid/filter.rb on lines 22..28
        lib/druid/filter.rb on lines 36..42
        lib/druid/filter.rb on lines 112..118
        lib/druid/having.rb on lines 31..37

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

        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