rubyjedi/soap4r

View on GitHub
lib/xsd/datatypes.rb

Summary

Maintainability
F
4 days
Test Coverage

File datatypes.rb has 1139 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'xsd/qname'
require 'xsd/charset'
require 'soap/nestedexception'
require 'uri'

Severity: Major
Found in lib/xsd/datatypes.rb - About 2 days to fix

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

      def screen_data(value)
        # "NaN".to_f => 0 in some environment.  libc?
        if value.is_a?(Float)
          return value
        end
    Severity: Minor
    Found in lib/xsd/datatypes.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 screen_data has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def screen_data(value)
        # "NaN".to_f => 0 in some environment.  libc?
        if value.is_a?(Float)
          return narrow32bit(value)
        end
    Severity: Minor
    Found in lib/xsd/datatypes.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 a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

      def _to_s
        str = ''
        str << @sign if @sign
        str << 'P'
        l = ''
    Severity: Minor
    Found in lib/xsd/datatypes.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 screen_data_str has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

      def screen_data_str(str)
        /^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ str.to_s.strip
        unless Regexp.last_match
          raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'.")
        end
    Severity: Minor
    Found in lib/xsd/datatypes.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 screen_data has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def screen_data(value)
        if value.is_a?(String)
          str = value.strip
          if str == 'true' || str == '1'
        true
    Severity: Minor
    Found in lib/xsd/datatypes.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 to_time has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def to_time
        begin
          if @data.offset * DayInSec == Time.now.utc_offset
            d = @data
            usec = (RUBY_VERSION.to_f >= 1.9) ? (d.sec_fraction * SecInMicro).to_i : (d.sec_fraction * DayInMicro).round
    Severity: Minor
    Found in lib/xsd/datatypes.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 screen_data has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def screen_data(t)
        # convert t to a DateTime as an internal representation.
        if t.respond_to?(:to_datetime)      # 1.9 or later
          t.to_datetime
        elsif t.is_a?(DateTime)
    Severity: Minor
    Found in lib/xsd/datatypes.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 narrow32bit has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def narrow32bit(f)
        if f.nan? || f.infinite?
          f
        elsif f.abs < MIN_POSITIVE_SINGLE
          XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO
    Severity: Minor
    Found in lib/xsd/datatypes.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 _to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def _to_s
        year = (@data.year > 0) ? @data.year : @data.year - 1
        s = format('%.4d-%02d-%02dT%02d:%02d:%02d', year, @data.mon, @data.mday, @data.hour, @data.min, @data.sec)
        if @data.sec_fraction.nonzero?
          if @secfrac
    Severity: Minor
    Found in lib/xsd/datatypes.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 _to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def _to_s
        if @data.nan?
          'NaN'
        elsif @data.infinite? == 1
          'INF'
    Severity: Minor
    Found in lib/xsd/datatypes.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 _to_s has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def _to_s
        if @data.nan?
          'NaN'
        elsif @data.infinite? == 1
          'INF'
    Severity: Minor
    Found in lib/xsd/datatypes.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 screen_data has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

      def screen_data(value)
        /^([+\-]?)P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)D)?(T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?)?$/ =~ value.to_s.strip
        unless Regexp.last_match
          raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.")
        end
    Severity: Minor
    Found in lib/xsd/datatypes.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 XSDNormalizedString < XSDString
      Type = QName.new(Namespace, NormalizedStringLiteral)
    
      def initialize(value = nil)
        init(Type, value)
    Severity: Minor
    Found in lib/xsd/datatypes.rb and 1 other location - About 30 mins to fix
    lib/xsd/datatypes.rb on lines 1036..1051

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

    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 XSDLanguage < XSDToken
      Type = QName.new(Namespace, LanguageLiteral)
    
      def initialize(value = nil)
        init(Type, value)
    Severity: Minor
    Found in lib/xsd/datatypes.rb and 1 other location - About 30 mins to fix
    lib/xsd/datatypes.rb on lines 1000..1014

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

    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