styd/apexcharts.rb

View on GitHub

Showing 13 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

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

          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

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

          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

          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

          Severity
          Category
          Status
          Source
          Language