Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ Style/StderrPuts:
Style/StringConcatenation:
Exclude:
- 'lib/annotate/annotate_models.rb'
- 'lib/annotate/annotate_routes/helpers.rb'

# Offense count: 57
# Cop supports --auto-correct.
Expand Down Expand Up @@ -817,4 +818,4 @@ Style/TrailingCommaInArrayLiteral:
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 264
Max: 245
10 changes: 9 additions & 1 deletion lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ module AnnotateModels
}
}.freeze

MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*(?:\n|r\n))|(^# coding:.*(?:\n|\r\n))|(^# -\*- coding:.*(?:\n|\r\n))|(^# -\*- encoding\s?:.*(?:\n|\r\n))|(^#\s*frozen_string_literal:.+(?:\n|\r\n))|(^# -\*- frozen_string_literal\s*:.+-\*-(?:\n|\r\n))/).freeze
MAGIC_COMMENT_MATCHER = Regexp.new(
'(^#\s*encoding:.*(?:\n|\r\n))' \
+ '|(^# coding:.*(?:\n|\r\n))' \
+ '|(^# -\*- coding:.*(?:\n|\r\n))' \
+ '|(^# -\*- encoding\s?:.*(?:\n|\r\n))' \
+ '|(^#\s*frozen_string_literal:.+(?:\n|\r\n))' \
+ '|(^# -\*- frozen_string_literal\s*:.+-\*-(?:\n|\r\n))' \
+ '|(^#\s*typed:.+(?:\n|\r\n))'
).freeze

class << self
def annotate_pattern(options = {})
Expand Down
10 changes: 9 additions & 1 deletion lib/annotate/annotate_routes/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
module AnnotateRoutes
module Helpers
MAGIC_COMMENT_MATCHER = Regexp.new(/(^#\s*encoding:.*)|(^# coding:.*)|(^# -\*- coding:.*)|(^# -\*- encoding\s?:.*)|(^#\s*frozen_string_literal:.+)|(^# -\*- frozen_string_literal\s*:.+-\*-)/).freeze
MAGIC_COMMENT_MATCHER = Regexp.new(
'(^#\s*encoding:.*)' \
+ '|(^# coding:.*)' \
+ '|(^# -\*- coding:.*)' \
+ '|(^# -\*- encoding\s?:.*)' \
+ '|(^#\s*frozen_string_literal:.+)' \
+ '|(^# -\*- frozen_string_literal\s*:.+-\*-)' \
+ '|(^#\s*typed:.*)'
).freeze

class << self
# TODO: write the method doc using ruby rdoc formats
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"# frozen_string_literal: true\n# encoding: utf-8",
'# frozen_string_literal: true',
'#frozen_string_literal: false',
'# -*- frozen_string_literal : true -*-'
'# -*- frozen_string_literal : true -*-',
'#typed: false',
'# typed: true'
].freeze unless const_defined?(:MAGIC_COMMENTS)

def mock_index(name, params = {})
Expand Down
4 changes: 3 additions & 1 deletion spec/lib/annotate/annotate_routes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
"# frozen_string_literal: true\n# encoding: utf-8",
'# frozen_string_literal: true',
'#frozen_string_literal: false',
'# -*- frozen_string_literal : true -*-'
'# -*- frozen_string_literal : true -*-',
'#typed: false',
'# typed: true'
].freeze unless const_defined?(:MAGIC_COMMENTS)

let :stubs do
Expand Down