Patch #24382

More readable regex for parse_redmine_links

Added by Dmitry Lisichkin 11 months ago. Updated 10 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Code cleanup/refactoring
Target version:3.4.0

Description

In method parse_redmine_links used very long regex that impossible to understand with first look.
Added names for capture groups.

parse_redmine_links_regexp_simplify.patch Magnifier (2.74 KB) Dmitry Lisichkin, 2016-11-16 12:32

parse_redmine_links_regexp_simplify1.patch Magnifier (2.73 KB) Dmitry Lisichkin, 2016-12-23 08:22

Associated revisions

Revision 16152
Added by Jean-Philippe Lang 10 months ago

More readable regexp for parse_redmine_links (#24382).

Patch by Dmitry Lisichkin.

History

#1 Updated by Toshi MARUYAMA 11 months ago

  • Target version set to 3.4.0

#2 Updated by Jean-Philippe Lang 10 months ago

  • Status changed from New to Needs feedback

Breaks a test:

ruby test\unit\helpers\application_helper_test.rb
DL is deprecated, please use Fiddle
Run options: --seed 7252

# Running:

.............................................................E..................
....................

Finished in 2.519144s, 39.6960 runs/s, 154.0206 assertions/s.

  1) Error:
ApplicationHelperTest#test_parse_redmine_links_should_handle_a_tag_without_attri
butes:
NoMethodError: undefined method `+' for nil:NilClass
    app/helpers/application_helper.rb:943:in `block in parse_redmine_links'
    app/helpers/application_helper.rb:800:in `gsub!'
    app/helpers/application_helper.rb:800:in `parse_redmine_links'
    test/unit/helpers/application_helper_test.rb:1279:in `test_parse_redmine_lin
ks_should_handle_a_tag_without_attributes'

100 runs, 388 assertions, 0 failures, 1 errors, 0 skips

#3 Updated by Dmitry Lisichkin 10 months ago

Sorry, wrong place for "tag_content" capture group.
Fixed.

#4 Updated by Go MAEDA 10 months ago

  • Category changed from Text formatting to Code cleanup/refactoring

#5 Updated by Jean-Philippe Lang 10 months ago

  • Subject changed from simplified regex for parse_redmine_links to More readable regex for parse_redmine_links
  • Status changed from Needs feedback to Closed
  • Assignee set to Jean-Philippe Lang

Committed, thanks for fixing the patch.

#6 Updated by Mischa The Evil 10 months ago

Dmitry, that's a nice refactoring making the method a lot more readable and thus easier to understand.

Also available in: Atom PDF