cqfn / pdd

Command line toolkit for collecting TODO markers from your code, known as Puzzle Driven Development (PDD)
https://www.0pdd.com
MIT License
76 stars 25 forks source link

[Refactoring] Checking puzzles rules not for every line #197

Closed Doldrums closed 2 years ago

Doldrums commented 2 years ago

Right now we have the following structure so there are several useless regexp compling calls due to avoiding .include? 'todo' line.

def check_rules(line)
      /[^\s]\x40todo/.match(line) do |_|
        raise Error, get_no_leading_space_error("\x40todo")
      end
  ...
  end    
...
 def match_markers(l)
      if l.downcase.include? 'todo'
...

begin
          check_rules(line)
          match_markers(line).each do |m|
            puzzles << puzzle(lines.drop(idx + 1), m, idx)
          end
....