@@ -60,8 +60,7 @@ class StringsFileValidationHelper
60
60
}
61
61
} . freeze
62
62
63
- # Inspects the given `.strings` file for duplicated keys, returning them
64
- # if any.
63
+ # Inspects the given `.strings` file for duplicated keys, returning them if any.
65
64
#
66
65
# @param [String] file The path to the file to inspect.
67
66
# @return [Hash<String, Array<Int>] Hash with the dublipcated keys.
@@ -73,12 +72,10 @@ def self.find_duplicated_keys(file:)
73
72
74
73
File . readlines ( file ) . each_with_index do |line , line_no |
75
74
line . chars . each_with_index do |c , col_no |
76
- # Handle escaped characters at a global level. This is more
77
- # straightforward than having a `TRANSITIONS` table that account
78
- # for it.
75
+ # Handle escaped characters at a global level.
76
+ # This is more straightforward than having a `TRANSITIONS` table that account for it.
79
77
if state . in_escaped_ctx || c == '\\'
80
- # Just because we check for escaped characters at the global
81
- # level, it doesn't mean we allow them in every context.
78
+ # Just because we check for escaped characters at the global level, it doesn't mean we allow them in every context.
82
79
allowed_contexts_for_escaped_characters = %i[ in_quoted_key in_quoted_value in_block_comment in_line_comment ]
83
80
raise "Found escaped character outside of allowed contexts on line #{ line_no + 1 } (current context: #{ state . context } )" unless allowed_contexts_for_escaped_characters . include? ( state . context )
84
81
@@ -87,16 +84,14 @@ def self.find_duplicated_keys(file:)
87
84
next
88
85
end
89
86
90
- # Look at the transitions table for the current context, and find
91
- # the first transition matching the current character
87
+ # Look at the transitions table for the current context, and find the first transition matching the current character
92
88
( _ , next_context ) = TRANSITIONS [ state . context ] . find { |regex , _ | c . match? ( regex ) } || [ nil , nil ]
93
89
raise "Invalid character `#{ c } ` found on line #{ line_no + 1 } , col #{ col_no + 1 } " if next_context . nil?
94
90
95
91
state . context = next_context . is_a? ( Proc ) ? next_context . call ( state , c ) : next_context
96
92
next unless state . found_key
97
93
98
- # If we just exited the :in_quoted_key context and thus have found
99
- # a new key, process it
94
+ # If we just exited the :in_quoted_key context and thus have found a new key, process it
100
95
key = state . found_key . dup
101
96
state . found_key = nil
102
97
0 commit comments