riboseinc/ruby-vobject

View on GitHub
lib/vobject/vcalendar/propertyvalue.rb

Summary

Maintainability
D
2 days
Test Coverage

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

require "vobject"
require "vobject/propertyvalue"

module Vobject
  module Vcalendar
Severity: Major
Found in lib/vobject/vcalendar/propertyvalue.rb - About 1 day to fix

    Method valencode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

            def valencode(k, v)
              case k
              when :bysetpos, :byyearday
                v.map do |x|
                  ret = x[:ordyrday]
    Severity: Minor
    Found in lib/vobject/vcalendar/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 valencode has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            def valencode(k, v)
              case k
              when :bysetpos, :byyearday
                v.map do |x|
                  ret = x[:ordyrday]
    Severity: Minor
    Found in lib/vobject/vcalendar/propertyvalue.rb - About 1 hr to fix

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

              def to_s
                ret = "P"
                ret = value[:sign] + ret if value[:sign]
                ret = ret + "#{value[:weeks]}W" if value[:weeks]
                ret = ret + "#{value[:days]}D" if value[:days]
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.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

                value[:time] = if val[:zone].nil? || val[:zone].empty?
                                 ::Time.local(val[:year], val[:month], val[:day], val[:hour], val[:min], val[:sec])
                               else
                                 ::Time.utc(val[:year], val[:month], val[:day], val[:hour], val[:min], val[:sec])
                               end
      Severity: Major
      Found in lib/vobject/vcalendar/propertyvalue.rb and 1 other location - About 1 hr to fix
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 191..195

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

      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 Utcoffset < Vobject::PropertyValue
              def initialize(val)
                self.value = val
                self.type = "utcoffset"
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 1 other location - About 45 mins to fix
      lib/vobject/vcard/v4_0/propertyvalue.rb on lines 283..296

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

      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

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

              def to_hash
                ret = {
                  year: value[:year],
                  month: value[:month],
                  day: value[:day],
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 1 other location - About 45 mins to fix
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 215..225

      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

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

            class Geovalue < Vobject::PropertyValue
              def initialize(val)
                self.value = val
                self.type = "geovalue"
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 1 other location - About 20 mins to fix
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 267..279

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

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

            class Float < Vobject::PropertyValue
              include Comparable
              def <=>(another)
                value <=> another.value
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 3 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 197..213
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 140..156
      lib/vobject/vcard/v4_0/propertyvalue.rb on lines 128..144

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

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

            class Integer < Vobject::PropertyValue
              include Comparable
              def <=>(another)
                value <=> another.value
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 3 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 177..193
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 140..156
      lib/vobject/vcard/v4_0/propertyvalue.rb on lines 128..144

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

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

            class Datetimeutclist < Vobject::PropertyValue
              def initialize(val)
                self.value = val
                self.type = "datetimeutclist"
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 2 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 478..489
      lib/vobject/vcalendar/propertyvalue.rb on lines 493..504

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

      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

                when :bymonthday
                  v.map do |x|
                    ret = x[:ordmoday]
                    ret = x[:sign] + ret if x[:sign]
                    ret
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 1 other location - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 576..581

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

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

            class Datetimelist < Vobject::PropertyValue
              def initialize(val)
                self.value = val
                self.type = "datetimelist"
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 2 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 478..489
      lib/vobject/vcalendar/propertyvalue.rb on lines 508..519

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

      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

                when :byweekno
                  v.map do |x|
                    ret = x[:ordwk]
                    ret = x[:sign] + ret if x[:sign]
                    ret
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 1 other location - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 582..587

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

      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

            class Textlist < Vobject::PropertyValue
              def initialize(val)
                self.value = val
                self.type = "textlist"
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 4 other locations - About 15 mins to fix
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 298..309
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 355..366
      lib/vobject/vcard/v4_0/propertyvalue.rb on lines 332..343
      lib/vobject/vcard/v4_0/propertyvalue.rb on lines 347..358

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

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

            class Datelist < Vobject::PropertyValue
              def initialize(val)
                self.value = val
                self.type = "datelist"
              end
      Severity: Minor
      Found in lib/vobject/vcalendar/propertyvalue.rb and 2 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 493..504
      lib/vobject/vcalendar/propertyvalue.rb on lines 508..519

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

      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

      There are no issues that match your filters.

      Category
      Status