CDLUC3/datacite-mapping

View on GitHub

Showing 3 of 9 total issues

Class Resource has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Resource # rubocop:disable Metrics/ClassLength
      include XML::MappingExtensions::Namespaced

      # Shadows Namespaced::ClassMethods.namespace
      def namespace
Severity: Minor
Found in lib/datacite/mapping/resource.rb - About 3 hrs to fix

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

          def initialize(val) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
            datetime = to_datetime(val)
            @date = datetime ? datetime.to_date : to_date(val)
            @year = to_year(val)
            @month = to_month(val)
    Severity: Minor
    Found in lib/datacite/mapping/date_value.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 value= has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def value=(val) # rubocop:disable Metrics/AbcSize
            parts = val.to_s.split('/', -1) # negative limit so we don't drop trailing empty string
            @date_value, @range_start, @range_end = nil
            case parts.size
            when 1
    Severity: Minor
    Found in lib/datacite/mapping/date.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

    Severity
    Category
    Status
    Source
    Language