boblail/pericope

View on GitHub

Showing 13 of 13 total issues

Method well_formatted_reference has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

  def well_formatted_reference(options={})
    verse_range_separator = options.fetch(:verse_range_separator, "–") # en-dash
    chapter_range_separator = options.fetch(:chapter_range_separator, "—") # em-dash
    verse_list_separator = options.fetch(:verse_list_separator, ", ")
    chapter_list_separator = options.fetch(:chapter_list_separator, "; ")
Severity: Minor
Found in lib/pericope.rb - About 5 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 parse_ranges has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_ranges(book, ranges)
      default_chapter = nil
      default_chapter = 1 unless book_has_chapters?(book)
      default_verse = nil

Severity: Minor
Found in lib/pericope/parsing.rb - About 3 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

Class Pericope has 24 methods (exceeds 20 allowed). Consider refactoring.
Open

class Pericope
  extend Pericope::Parsing
  include Enumerable

  attr_reader :book, :original_string, :ranges
Severity: Minor
Found in lib/pericope.rb - About 2 hrs to fix

    Method well_formatted_reference has 40 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def well_formatted_reference(options={})
        verse_range_separator = options.fetch(:verse_range_separator, "–") # en-dash
        chapter_range_separator = options.fetch(:chapter_range_separator, "—") # em-dash
        verse_list_separator = options.fetch(:verse_list_separator, ", ")
        chapter_list_separator = options.fetch(:chapter_list_separator, "; ")
    Severity: Minor
    Found in lib/pericope.rb - About 1 hr to fix

      Method parse_ranges has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def parse_ranges(book, ranges)
            default_chapter = nil
            default_chapter = 1 unless book_has_chapters?(book)
            default_verse = nil
      
      
      Severity: Minor
      Found in lib/pericope/parsing.rb - About 1 hr to fix

        Method split has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def split(text)
              segments = []
              start = 0
        
              match_all(text) do |attributes, match|
        Severity: Minor
        Found in lib/pericope/parsing.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

        Consider simplifying this complex logical expression.
        Open

              if !always_print_verse_range && range.begin.verse == 1 && range.begin.whole? && (range.end.verse > last_verse || range.end.whole? && range.end.verse == last_verse) && (touched_chapters - [range.begin.chapter]).none?
                s << range.begin.chapter.to_s
                s << "#{chapter_range_separator}#{range.end.chapter}" if range.end.chapter > range.begin.chapter
              else
                if range.begin.partial? && range.begin.verse == recent_verse
        Severity: Major
        Found in lib/pericope.rb - About 1 hr to fix

          Method group_array_into_ranges has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def group_array_into_ranges(verses)
              return [] if verses.nil? or verses.empty?
          
              verses = verses.flatten.compact.sort.map { |verse| Verse.parse(verse) }
          
          
          Severity: Minor
          Found in lib/pericope.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 next has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def next
                if partial? && (next_letter = letter.succ) <= Pericope.max_letter
                  return self.class.new(book, chapter, verse, next_letter)
                end
          
          
          Severity: Minor
          Found in lib/pericope/verse.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 parse_reference_fragment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_reference_fragment(input, default_chapter: nil, default_verse: nil)
                chapter, verse, letter = input.match(Pericope.fragment_regexp).captures
                chapter = default_chapter unless chapter
                chapter, verse = [verse, nil] unless chapter
                verse = default_verse unless verse
          Severity: Minor
          Found in lib/pericope/parsing.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 initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def initialize(book, chapter, verse, letter=nil)
                super
          
                raise ArgumentError, "#{book} is not a valid book" if book < 1 || book > 66
                raise ArgumentError, "#{chapter} is not a valid chapter" if chapter < 1 || chapter > Pericope.get_max_chapter(book)
          Severity: Minor
          Found in lib/pericope/verse.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 intersects? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def intersects?(other)
              return false unless other.is_a?(Pericope)
              return false unless book == other.book
          
              ranges.each do |self_range|
          Severity: Minor
          Found in lib/pericope.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 each has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def each
                return to_enum unless block_given?
          
                if self.begin == self.end
                  yield self.begin
          Severity: Minor
          Found in lib/pericope/range.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

          Severity
          Category
          Status
          Source
          Language