riboseinc/ruby-vobject

View on GitHub

Showing 79 of 214 total issues

Method property_parent has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

      def property_parent(strict, key, component, _value, ctx1)
        errors = []
        if key !~ /^x/i && registered_propname?(key.to_s)
          case component
          when :EVENT
Severity: Minor
Found in lib/vobject/vcalendar/propertyparent.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 vobject_grammar has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

    def vobject_grammar
      # properties with value cardinality 1
      @cardinality1 = {}
      @cardinality1[:PARAM] = Set.new [:VALUE]
      @cardinality1[:PROP] = Set.new [:KIND, :N, :BDAY, :ANNIVERSARY, :GENDER, :PRODID, :REV, :UID, :BIRTHPLACE, :DEATHPLACE, :DEATHDATE]
Severity: Minor
Found in lib/vobject/vcard/v4_0/grammar.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 fivepartname has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

      def fivepartname
        text = C::TEXT3
        component = seq(text << ",".r, lazy { component }) do |(a, b)|
          [unescape(a), b].flatten
        end | text.map { |t| [unescape(t)] }
Severity: Minor
Found in lib/vobject/vcard/v3_0/typegrammars.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 typematch has 110 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def typematch(strict, key, params, _component, value)
        errors = []
        ctx1 = Rsec::ParseContext.new value, "source"
        case key
        when :VERSION
Severity: Major
Found in lib/vobject/vcard/v4_0/typegrammars.rb - About 4 hrs to fix

    Method typematch has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

          def typematch(strict, key, params, _component, value, ctx)
            errors = []
            params[:VALUE] = params[:VALUE].downcase if params && params[:VALUE]
            ctx1 = Rsec::ParseContext.new value, "source"
            case key
    Severity: Minor
    Found in lib/vobject/vcard/v3_0/typegrammars.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

    File propertyvalue.rb has 340 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require "vobject"
    require "vobject/propertyvalue"
    
    module Vcard::V4_0
      module PropertyValue
    Severity: Minor
    Found in lib/vobject/vcard/v4_0/propertyvalue.rb - About 4 hrs to fix

      File propertyvalue.rb has 332 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require "vobject"
      require "vobject/propertyvalue"
      
      module Vcard::V3_0
        module PropertyValue
      Severity: Minor
      Found in lib/vobject/vcard/v3_0/propertyvalue.rb - About 4 hrs to fix

        Class Typegrammars has 30 methods (exceeds 20 allowed). Consider refactoring.
        Open

          class Typegrammars
            class << self
              # property value types, each defining their own parser
              def integer
                integer = prim(:int32).map { |i| PropertyValue::Integer.new i }
        Severity: Minor
        Found in lib/vobject/vcard/v4_0/typegrammars.rb - About 3 hrs to fix

          Method vobject_grammar has 91 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def vobject_grammar
                # properties with value cardinality 1
                @cardinality1 = {}
                @cardinality1[:PARAM] = Set.new [:VALUE]
                @cardinality1[:PROP] = Set.new [:KIND, :N, :BDAY, :ANNIVERSARY, :GENDER, :PRODID, :REV, :UID]
          Severity: Major
          Found in lib/vobject/vcard/v3_0/grammar.rb - About 3 hrs to fix

            Method recur has 91 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def recur
                    freq = /SECONDLY/i.r | /MINUTELY/i.r | /HOURLY/i.r | /DAILY/i.r |
                      /WEEKLY/i.r | /MONTHLY/i.r | /YEARLY/i.r
                    enddate = C::DATE_TIME | C::DATE
                    seconds = /[0-9]{1,2}/.r
            Severity: Major
            Found in lib/vobject/vcalendar/typegrammars.rb - About 3 hrs to fix

              Method typematch has 80 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def typematch(strict, key, params, _component, value, ctx)
                      errors = []
                      params[:VALUE] = params[:VALUE].downcase if params && params[:VALUE]
                      ctx1 = Rsec::ParseContext.new value, "source"
                      case key
              Severity: Major
              Found in lib/vobject/vcard/v3_0/typegrammars.rb - About 3 hrs to fix

                Method property_parent has 79 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def property_parent(strict, key, component, _value, ctx1)
                        errors = []
                        if key !~ /^x/i && registered_propname?(key.to_s)
                          case component
                          when :EVENT
                Severity: Major
                Found in lib/vobject/vcalendar/propertyparent.rb - About 3 hrs to fix

                  Method paramcheck has 76 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                        def paramcheck(strict, prop, params, ctx)
                          errors = []
                          if params && params[:TYPE]
                            parse_err(strict, errors, "multiple values for :TYPE parameter of #{prop}", ctx) if params[:TYPE].is_a?(Array) && params[:TYPE].length > 1 && prop != :EMAIL && prop != :ADR && prop != :TEL && prop != :LABEL && prop != :IMPP
                          end
                  Severity: Major
                  Found in lib/vobject/vcard/v3_0/paramcheck.rb - About 3 hrs to fix

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

                      class Typegrammars
                        class << self
                          # property value types, each defining their own parser
                    
                          def binary
                    Severity: Minor
                    Found in lib/vobject/vcard/v3_0/typegrammars.rb - About 3 hrs to fix

                      Consider simplifying this complex logical expression.
                      Open

                                if @cardinality1[:PROP].include?(key.upcase) &&
                                  !(new.is_a?(Array) &&
                                    new[0].key?(:params) && new[0][:params].key?(:ALTID) &&
                                    old.key?(:params) && old[:params].key?(:ALTID) &&
                                    old[:params][:ALTID] == new[0][:params][:ALTID]) &&
                      Severity: Critical
                      Found in lib/vobject/vcard/v4_0/grammar.rb - About 3 hrs to fix

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

                            def initialize(key, cs)
                              # super key, cs
                              self.comp_name = key
                              raise_invalid_initialization if key != name
                        
                        
                        Severity: Minor
                        Found in lib/vobject/vcalendar/component.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 timezoneadjust has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def timezoneadjust(x)
                              if x[:TZID].nil? || x[:TZID].empty?
                                return x
                              end
                              # TODO deal with unregistered timezones
                        Severity: Major
                        Found in lib/vobject/vcalendar/grammar.rb - About 2 hrs to fix

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

                                def initialize(val)
                                  self.value = val.clone
                                  # val consists of :time && :zone values. If :zone is empty, floating local time (i.e. system local time) is assumed
                                  self.type = "date-time"
                                  # fill in unspecified month && year && date; only for purposes of comparison
                          Severity: Minor
                          Found in lib/vobject/vcard/v4_0/propertyvalue.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 date_and_or_time has 68 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                                def date_and_or_time
                                  hour = /[0-9]{2}/.r
                                  minute = /[0-9]{2}/.r
                                  second = /[0-9]{2}/.r
                                  time_notrunc = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
                          Severity: Major
                          Found in lib/vobject/vcard/v4_0/typegrammars.rb - About 2 hrs to fix

                            Method date_and_or_time has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                            Open

                                  def date_and_or_time
                                    hour = /[0-9]{2}/.r
                                    minute = /[0-9]{2}/.r
                                    second = /[0-9]{2}/.r
                                    time_notrunc = seq(hour, minute, second, C::ZONE._?) do |(h, m, s, z)|
                            Severity: Minor
                            Found in lib/vobject/vcard/v4_0/typegrammars.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

                            Severity
                            Category
                            Status
                            Source
                            Language