icalendar/icalendar

View on GitHub

Showing 23 of 23 total issues

Method parse_fields has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_fields(value)
        {
          frequency: (value =~ /FREQ=(SECONDLY|MINUTELY|HOURLY|DAILY|WEEKLY|MONTHLY|YEARLY)/i ? $1.upcase : nil),
          until: (value =~ /UNTIL=([^;]*)/i ? $1 : nil),
          count: (value =~ /COUNT=(\d+)/i ? $1.to_i : nil),
Severity: Minor
Found in lib/icalendar/values/recur.rb - 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

Method value_ical has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def value_ical
        builder = ["FREQ=#{frequency}"]
        builder << "UNTIL=#{self.until}" unless self.until.nil?
        builder << "COUNT=#{count}" unless count.nil?
        builder << "INTERVAL=#{interval}" unless interval.nil?
Severity: Minor
Found in lib/icalendar/values/recur.rb - About 3 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

Method parse_component has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_component(component)
      while (fields = next_fields)
        if fields[:name] == 'end'
          klass_name = fields[:value].gsub(/\AV/, '').downcase.capitalize
          timezone_store.store(component) if klass_name == 'Timezone'
Severity: Minor
Found in lib/icalendar/parser.rb - About 2 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

Method parse_fields has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_fields(input)
      if parts = %r{#{LINE}}.match(input)
        value = parts[:value]
      else
        parts = %r{#{BAD_LINE}}.match(input) unless strict?
Severity: Minor
Found in lib/icalendar/parser.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 initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(value, params = {})
        params = Icalendar::DowncasedHash(params)
        @tz_utc = params['tzid'] == 'UTC'
        x_tz_info = params.delete 'x-tz-info'

Severity: Minor
Found in lib/icalendar/values/time_with_zone.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 parse_fields has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def parse_fields(value)
        {
          past: (value =~ /\A([+-])P/ ? $1 == '-' : false),
          weeks: (value =~ /(\d+)W/ ? $1.to_i : 0),
          days: (value =~ /(\d+)D/ ? $1.to_i : 0),
Severity: Minor
Found in lib/icalendar/values/duration.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 component has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def component(singular_name, find_by = :uid, klass = nil)
        components = "#{singular_name}s"
        self.components << components
        component_var = "@#{components}"

Severity: Minor
Found in lib/icalendar/has_components.rb - About 1 hr to fix

    Method parse_fields has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def parse_fields(input)
          if parts = %r{#{LINE}}.match(input)
            value = parts[:value]
          else
            parts = %r{#{BAD_LINE}}.match(input) unless strict?
    Severity: Minor
    Found in lib/icalendar/parser.rb - About 1 hr to fix

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

            def component(singular_name, find_by = :uid, klass = nil)
              components = "#{singular_name}s"
              self.components << components
              component_var = "@#{components}"
      
      
      Severity: Minor
      Found in lib/icalendar/has_components.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 initialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(value, klass, params = {}, options = {})
              @value_delimiter = options[:delimiter] || ','
              mapped = if value.is_a? ::Array
                         value.map do |v|
                           if v.is_a? Icalendar::Values::Array
      Severity: Minor
      Found in lib/icalendar/values/array.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 value_ical has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

            def value_ical
              return "#{'-' if past?}P#{weeks}W" if weeks > 0
              builder = []
              builder << '-' if past?
              builder << 'P'
      Severity: Minor
      Found in lib/icalendar/values/duration.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 parse_property has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_property(component, fields = nil)
            fields = next_fields if fields.nil?
            prop_name = %w(class method).include?(fields[:name]) ? "ip_#{fields[:name]}" : fields[:name]
            multi_property = component.class.multiple_properties.include? prop_name
            prop_value = wrap_property_value component, fields, multi_property
      Severity: Minor
      Found in lib/icalendar/parser.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 ical_properties has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def ical_properties
            (self.class.properties + custom_properties.keys).map do |prop|
              value = property prop
              unless value.nil?
                if value.is_a? ::Array
      Severity: Minor
      Found in lib/icalendar/component.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 offset_for_local has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def offset_for_local(local)
            standard = standard_for local
            daylight = daylight_for local
      
            if standard.nil? && daylight.nil?
      Severity: Minor
      Found in lib/icalendar/timezone.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 wrap_property_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def wrap_property_value(component, fields, multi_property)
            klass = get_wrapper_class component, fields
            if wrap_in_array? klass, fields[:value], multi_property
              delimiter = fields[:value].match(/(?<!\\)([,;])/)[1]
              Icalendar::Values::Array.new fields[:value].split(/(?<!\\)[;,]/),
      Severity: Minor
      Found in lib/icalendar/parser.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 get_wrapper_class has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def get_wrapper_class(component, fields)
            klass = component.class.default_property_types[fields[:name]]
            if !fields[:params]['value'].nil?
              klass_name = fields[:params].delete('value').first
              unless klass_name.upcase == klass.value_type
      Severity: Minor
      Found in lib/icalendar/parser.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 map_property_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def map_property_value(value, klass, multi_valued)
            if value.nil? || value.is_a?(Icalendar::Value)
              value
            elsif value.is_a? ::Array
              Icalendar::Values::Array.new value, klass, {}, {delimiter: (multi_valued ? ',' : ';')}
      Severity: Minor
      Found in lib/icalendar/has_properties.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(value, params = {})
              if value.is_a? String
                params['tzid'] = 'UTC' if value.end_with? 'Z'
      
                begin
      Severity: Minor
      Found in lib/icalendar/values/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 method_missing has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def method_missing(method, *args, &block)
            method_name = method.to_s
            if method_name =~ /^add_(x_\w+)$/
              component_name = $1
              custom = args.first || Component.new(component_name, component_name.upcase)
      Severity: Minor
      Found in lib/icalendar/has_components.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 ical_timezone has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def ical_timezone(date, dst = Timezone.default_dst)
            period = period_for_local(date, dst)
            timezone = Icalendar::Timezone.new
            timezone.tzid = identifier
            if period.start_transition.nil?
      Severity: Minor
      Found in lib/icalendar/tzinfo.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