styd/apexcharts.rb

View on GitHub

Showing 34 of 34 total issues

Class OptionsBuilder has 31 methods (exceeds 20 allowed). Consider refactoring.
Open

  class OptionsBuilder
    include ApexCharts::Utils::Hash
    include ApexCharts::Utils::DateTime

    attr_accessor :built
Severity: Minor
Found in lib/apex_charts/options_builder.rb - About 3 hrs to fix

    File options_builder.rb has 311 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module ApexCharts
      class OptionsBuilder
        include ApexCharts::Utils::Hash
        include ApexCharts::Utils::DateTime
    
    
    Severity: Minor
    Found in lib/apex_charts/options_builder.rb - About 3 hrs to fix

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

      module.exports = function(api) {
        var validEnv = ['development', 'test', 'production']
        var currentEnv = api.env()
        var isDevelopmentEnv = api.env('development')
        var isProductionEnv = api.env('production')
      Severity: Major
      Found in examples/rails/babel.config.js - About 2 hrs to fix

        Method build_yaxis has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def build_yaxis
              yaxis = @options.delete :yaxis
        
              case yaxis
              when Array
        Severity: Minor
        Found in lib/apex_charts/options_builder.rb - About 1 hr to fix

          Method build_chart has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def build_chart
                built[:chart] =
                  if target = @options.delete(:brushTarget)
                    {
                      brush: {enabled: true, target: target.to_s},
          Severity: Minor
          Found in lib/apex_charts/options_builder.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

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

              def build_selection_range
                last_data = @series[:series].last[:data]
                first_x = last_data.first[:x]
                last_x = last_data.last[:x]
                @options[:chart][:selection][:xaxis] = {
          Severity: Minor
          Found in lib/apex_charts/charts/mixed_charts.rb and 1 other location - About 35 mins to fix
          lib/apex_charts/charts/cartesian_chart.rb on lines 64..71

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

          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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(data)
                data = deep_copy(data)
                sanitized =
                  case data
                  when Array
          Severity: Minor
          Found in lib/apex_charts/series/bubble_series.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

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

              def build_yaxis
                yaxis = @options.delete :yaxis
          
                case yaxis
                when Array
          Severity: Minor
          Found in lib/apex_charts/options_builder.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

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

                def convert_range(input)
                  input_first, input_last = input.first, input.last
                  case input_first
                  when Time
                    to_milliseconds_range(input_first, input_last)
          Severity: Minor
          Found in lib/apex_charts/utils/date_time.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

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

              def build_selection_range
                last_data = @series[:series].last[:data]
                first_x = last_data.first[:x]
                last_x = last_data.last[:x]
                @options[:chart][:selection][:xaxis] = {
          Severity: Minor
          Found in lib/apex_charts/charts/cartesian_chart.rb and 1 other location - About 35 mins to fix
          lib/apex_charts/charts/mixed_charts.rb on lines 89..96

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

          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 convert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

                def convert(input)
                  case input
                  when Time
                    (input.to_f * 1000).round
                  when ::DateTime, Date
          Severity: Minor
          Found in lib/apex_charts/utils/date_time.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 5 locations. Consider refactoring.
          Open

              def column_chart(data, options={}, &block)
                options[:id] = apexcharts_id
                outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
                @html +=
                  ColumnChart.new(outer_self, data, @options.merge(options), &block).render
          Severity: Major
          Found in lib/apex_charts/charts/syncing_charts.rb and 4 other locations - About 25 mins to fix
          lib/apex_charts/charts/syncing_charts.rb on lines 17..22
          lib/apex_charts/charts/syncing_charts.rb on lines 24..29
          lib/apex_charts/charts/syncing_charts.rb on lines 31..36
          lib/apex_charts/charts/syncing_charts.rb on lines 45..50

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

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

              def bar_chart(data, options={}, &block)
                options[:id] = apexcharts_id
                outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
                @html +=
                  BarChart.new(outer_self, data, @options.merge(options), &block).render
          Severity: Major
          Found in lib/apex_charts/charts/syncing_charts.rb and 4 other locations - About 25 mins to fix
          lib/apex_charts/charts/syncing_charts.rb on lines 17..22
          lib/apex_charts/charts/syncing_charts.rb on lines 24..29
          lib/apex_charts/charts/syncing_charts.rb on lines 38..43
          lib/apex_charts/charts/syncing_charts.rb on lines 45..50

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

          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 annotation has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def annotation(axis, value:, text:, color: nil, **options)
                @annotations ||= {}
          
                raise "unrecognized axis: #{axis}" unless %i[xaxis yaxis points].include? axis
          
          
          Severity: Minor
          Found in lib/apex_charts/charts/features/annotations.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 annotation_value has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def annotation_value(axis, value)
                axis = axis.to_s.delete_suffix('axis').to_sym
                case value
                when Range
                  value = ApexCharts::Utils::DateTime.convert_range(value)
          Severity: Minor
          Found in lib/apex_charts/charts/features/annotations.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 type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                def type(input)
                  case input
                  when Time, ::DateTime, Date
                    'datetime'
                  else
          Severity: Minor
          Found in lib/apex_charts/utils/date_time.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

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

              def area_chart(data, options={}, &block)
                options[:id] = apexcharts_id
                outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
                @html +=
                  AreaChart.new(outer_self, data, @options.merge(options), &block).render
          Severity: Major
          Found in lib/apex_charts/charts/syncing_charts.rb and 4 other locations - About 25 mins to fix
          lib/apex_charts/charts/syncing_charts.rb on lines 17..22
          lib/apex_charts/charts/syncing_charts.rb on lines 31..36
          lib/apex_charts/charts/syncing_charts.rb on lines 38..43
          lib/apex_charts/charts/syncing_charts.rb on lines 45..50

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

          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 build_series_from_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def build_series_from_hash(data)
                if data_value = data[:data]
                  if array_of_pairs?(data_value)
                    data[:data] = array_of_array_to_array_of_xy(data_value)
                    [data]
          Severity: Minor
          Found in lib/apex_charts/series/cartesian_series.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

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

              def line_chart(data, options={}, &block)
                options[:id] = apexcharts_id
                outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
                @html +=
                  LineChart.new(outer_self, data, @options.merge(options), &block).render
          Severity: Major
          Found in lib/apex_charts/charts/syncing_charts.rb and 4 other locations - About 25 mins to fix
          lib/apex_charts/charts/syncing_charts.rb on lines 24..29
          lib/apex_charts/charts/syncing_charts.rb on lines 31..36
          lib/apex_charts/charts/syncing_charts.rb on lines 38..43
          lib/apex_charts/charts/syncing_charts.rb on lines 45..50

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

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

              def scatter_chart(data, options={}, &block)
                options[:id] = apexcharts_id
                outer_self = eval('self', block.binding, __FILE__, __LINE__) if block_given?
                @html +=
                  ScatterChart.new(outer_self, data, @options.merge(options), &block).render
          Severity: Major
          Found in lib/apex_charts/charts/syncing_charts.rb and 4 other locations - About 25 mins to fix
          lib/apex_charts/charts/syncing_charts.rb on lines 17..22
          lib/apex_charts/charts/syncing_charts.rb on lines 24..29
          lib/apex_charts/charts/syncing_charts.rb on lines 31..36
          lib/apex_charts/charts/syncing_charts.rb on lines 38..43

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

          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