riboseinc/ruby-vobject

View on GitHub
lib/vobject/vcard/v4_0/propertyvalue.rb

Summary

Maintainability
C
1 day
Test Coverage

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

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

          def to_s
            ret = ""
            ret << if value[:year]
                     value[:year]
                   else
    Severity: Minor
    Found in lib/vobject/vcard/v4_0/propertyvalue.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 to_s has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def to_s
            ret = ""
            ret << if value[:year]
                     value[:year]
                   else
    Severity: Minor
    Found in lib/vobject/vcard/v4_0/propertyvalue.rb - About 1 hr to fix

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

            def to_hash
              ret = {}
              ret[:year] = value[:year] if value[:year]
              ret[:month] = value[:month] if value[:month]
              ret[:day] = value[:day] if value[:day]
      Severity: Minor
      Found in lib/vobject/vcard/v4_0/propertyvalue.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 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def initialize(val)
              self.value = val.clone
              self.type = "date"
              # fill in unspecified month && year && date; only for purposes of comparison
              val[:year] = sprintf("%04d", ::Date.today.year) unless val.has_key?(:year)
      Severity: Minor
      Found in lib/vobject/vcard/v4_0/propertyvalue.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 2 locations. Consider refactoring.
      Open

          class Utcoffset < Vobject::PropertyValue
            def initialize(val)
              self.value = val
              self.type = "utc-offset"
            end
      Severity: Minor
      Found in lib/vobject/vcard/v4_0/propertyvalue.rb and 1 other location - About 45 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 391..404

      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

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

              def listencode(x)
                ret = if x.is_a?(Array)
                        x.map { |m| Text.escape_component m }.join(",")
                      elsif x.nil? || x.empty?
                        ""
      Severity: Minor
      Found in lib/vobject/vcard/v4_0/propertyvalue.rb and 1 other location - About 20 mins to fix
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 13..21

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

      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/vcard/v4_0/propertyvalue.rb and 3 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 177..193
      lib/vobject/vcalendar/propertyvalue.rb on lines 197..213
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 140..156

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

          class Textlist < Vobject::PropertyValue
            def initialize(val)
              self.value = val
              self.type = "text"
            end
      Severity: Minor
      Found in lib/vobject/vcard/v4_0/propertyvalue.rb and 4 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 443..454
      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 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 5 locations. Consider refactoring.
      Open

          class Org < Vobject::PropertyValue
            def initialize(val)
              self.value = val
              self.type = "text"
            end
      Severity: Minor
      Found in lib/vobject/vcard/v4_0/propertyvalue.rb and 4 other locations - About 15 mins to fix
      lib/vobject/vcalendar/propertyvalue.rb on lines 443..454
      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

      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

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

          class Float < Vobject::PropertyValue
            include Comparable
            def <=>(another)
              value <=> another.value
            end
      Severity: Minor
      Found in lib/vobject/vcard/v4_0/propertyvalue.rb and 1 other location - About 15 mins to fix
      lib/vobject/vcard/v3_0/propertyvalue.rb on lines 120..136

      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