Skip to content

Commit 860d628

Browse files
authored
Merge pull request #49 from envato/orien/rubocop
Address layout and frozen string literal issues
2 parents 55125e0 + 971988c commit 860d628

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+223
-344
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -6,170 +6,6 @@
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
# This cop supports safe autocorrection (--autocorrect).
10-
# Configuration parameters: EnforcedStyleAlignWith.
11-
# SupportedStylesAlignWith: either, start_of_block, start_of_line
12-
Layout/BlockAlignment:
13-
Exclude:
14-
- 'zxcvbn-ruby.gemspec'
15-
16-
# This cop supports safe autocorrection (--autocorrect).
17-
Layout/ElseAlignment:
18-
Exclude:
19-
- 'lib/zxcvbn/entropy.rb'
20-
21-
# This cop supports safe autocorrection (--autocorrect).
22-
Layout/EmptyLineAfterGuardClause:
23-
Exclude:
24-
- 'lib/zxcvbn/entropy.rb'
25-
- 'lib/zxcvbn/matchers/date.rb'
26-
- 'lib/zxcvbn/matchers/l33t.rb'
27-
- 'lib/zxcvbn/matchers/new_l33t.rb'
28-
- 'lib/zxcvbn/math.rb'
29-
- 'lib/zxcvbn/omnimatch.rb'
30-
31-
# This cop supports safe autocorrection (--autocorrect).
32-
Layout/EmptyLineAfterMagicComment:
33-
Exclude:
34-
- 'zxcvbn-ruby.gemspec'
35-
36-
# This cop supports safe autocorrection (--autocorrect).
37-
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
38-
Layout/EmptyLineBetweenDefs:
39-
Exclude:
40-
- 'lib/zxcvbn/omnimatch.rb'
41-
- 'lib/zxcvbn/scorer.rb'
42-
43-
# This cop supports safe autocorrection (--autocorrect).
44-
Layout/EmptyLines:
45-
Exclude:
46-
- 'lib/zxcvbn/omnimatch.rb'
47-
- 'lib/zxcvbn/scorer.rb'
48-
49-
# This cop supports safe autocorrection (--autocorrect).
50-
# Configuration parameters: EnforcedStyle.
51-
# SupportedStyles: empty_lines, no_empty_lines
52-
Layout/EmptyLinesAroundBlockBody:
53-
Exclude:
54-
- 'spec/scorer_spec.rb'
55-
- 'spec/scoring/entropy_spec.rb'
56-
57-
# This cop supports safe autocorrection (--autocorrect).
58-
# Configuration parameters: EnforcedStyle.
59-
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
60-
Layout/EmptyLinesAroundClassBody:
61-
Exclude:
62-
- 'lib/zxcvbn/matchers/new_l33t.rb'
63-
64-
# This cop supports safe autocorrection (--autocorrect).
65-
# Configuration parameters: EnforcedStyleAlignWith, Severity.
66-
# SupportedStylesAlignWith: keyword, variable, start_of_line
67-
Layout/EndAlignment:
68-
Exclude:
69-
- 'lib/zxcvbn/entropy.rb'
70-
71-
# This cop supports safe autocorrection (--autocorrect).
72-
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
73-
Layout/ExtraSpacing:
74-
Exclude:
75-
- 'lib/zxcvbn/scorer.rb'
76-
77-
# This cop supports safe autocorrection (--autocorrect).
78-
# Configuration parameters: IndentationWidth.
79-
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
80-
Layout/FirstArrayElementIndentation:
81-
EnforcedStyle: consistent
82-
83-
# This cop supports safe autocorrection (--autocorrect).
84-
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
85-
# SupportedHashRocketStyles: key, separator, table
86-
# SupportedColonStyles: key, separator, table
87-
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
88-
Layout/HashAlignment:
89-
Exclude:
90-
- 'lib/zxcvbn/data.rb'
91-
92-
# This cop supports safe autocorrection (--autocorrect).
93-
# Configuration parameters: Width, AllowedPatterns.
94-
Layout/IndentationWidth:
95-
Exclude:
96-
- 'lib/zxcvbn/entropy.rb'
97-
98-
# This cop supports safe autocorrection (--autocorrect).
99-
# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
100-
# URISchemes: http, https
101-
Layout/LineLength:
102-
Exclude:
103-
- 'Rakefile'
104-
- 'lib/zxcvbn/scorer.rb'
105-
106-
# This cop supports safe autocorrection (--autocorrect).
107-
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals.
108-
# SupportedStylesForExponentOperator: space, no_space
109-
# SupportedStylesForRationalLiterals: space, no_space
110-
Layout/SpaceAroundOperators:
111-
Exclude:
112-
- 'lib/zxcvbn/crack_time.rb'
113-
- 'lib/zxcvbn/entropy.rb'
114-
- 'lib/zxcvbn/matchers/repeat.rb'
115-
- 'lib/zxcvbn/matchers/sequences.rb'
116-
- 'lib/zxcvbn/matchers/spatial.rb'
117-
- 'lib/zxcvbn/scorer.rb'
118-
119-
# This cop supports safe autocorrection (--autocorrect).
120-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
121-
# SupportedStyles: space, no_space
122-
# SupportedStylesForEmptyBraces: space, no_space
123-
Layout/SpaceBeforeBlockBraces:
124-
Exclude:
125-
- 'lib/zxcvbn/entropy.rb'
126-
- 'lib/zxcvbn/matchers/l33t.rb'
127-
- 'lib/zxcvbn/matchers/new_l33t.rb'
128-
129-
# This cop supports safe autocorrection (--autocorrect).
130-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
131-
# SupportedStyles: space, no_space
132-
# SupportedStylesForEmptyBraces: space, no_space
133-
Layout/SpaceInsideBlockBraces:
134-
Exclude:
135-
- 'lib/zxcvbn/entropy.rb'
136-
- 'lib/zxcvbn/matchers/l33t.rb'
137-
- 'spec/spec_helper.rb'
138-
139-
# This cop supports safe autocorrection (--autocorrect).
140-
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
141-
# SupportedStyles: space, no_space, compact
142-
# SupportedStylesForEmptyBraces: space, no_space
143-
Layout/SpaceInsideHashLiteralBraces:
144-
Exclude:
145-
- 'lib/zxcvbn/matchers/new_l33t.rb'
146-
- 'spec/dictionary_ranker_spec.rb'
147-
- 'spec/matchers/l33t_spec.rb'
148-
- 'spec/scoring/entropy_spec.rb'
149-
- 'spec/zxcvbn_spec.rb'
150-
151-
# This cop supports safe autocorrection (--autocorrect).
152-
Layout/SpaceInsidePercentLiteralDelimiters:
153-
Exclude:
154-
- 'lib/zxcvbn/matchers/date.rb'
155-
- 'spec/matchers/date_spec.rb'
156-
157-
# This cop supports safe autocorrection (--autocorrect).
158-
# Configuration parameters: EnforcedStyle.
159-
# SupportedStyles: final_newline, final_blank_line
160-
Layout/TrailingEmptyLines:
161-
Exclude:
162-
- 'lib/zxcvbn/clock.rb'
163-
- 'lib/zxcvbn/crack_time.rb'
164-
- 'lib/zxcvbn/matchers/dictionary.rb'
165-
- 'lib/zxcvbn/matchers/l33t.rb'
166-
- 'lib/zxcvbn/matchers/new_l33t.rb'
167-
- 'lib/zxcvbn/matchers/spatial.rb'
168-
- 'lib/zxcvbn/matchers/year.rb'
169-
- 'lib/zxcvbn/score.rb'
170-
- 'spec/support/js_helpers.rb'
171-
- 'spec/support/matcher.rb'
172-
1739
# This cop supports unsafe autocorrection (--autocorrect-all).
17410
# Configuration parameters: AllowSafeAssignment.
17511
Lint/AssignmentInCondition:
@@ -416,59 +252,6 @@ Style/For:
416252
- 'lib/zxcvbn/feedback_giver.rb'
417253
- 'lib/zxcvbn/matchers/date.rb'
418254

419-
# This cop supports unsafe autocorrection (--autocorrect-all).
420-
# Configuration parameters: EnforcedStyle.
421-
# SupportedStyles: always, always_true, never
422-
Style/FrozenStringLiteralComment:
423-
Exclude:
424-
- '**/*.arb'
425-
- 'Gemfile'
426-
- 'Guardfile'
427-
- 'Rakefile'
428-
- 'lib/zxcvbn.rb'
429-
- 'lib/zxcvbn/clock.rb'
430-
- 'lib/zxcvbn/crack_time.rb'
431-
- 'lib/zxcvbn/data.rb'
432-
- 'lib/zxcvbn/dictionary_ranker.rb'
433-
- 'lib/zxcvbn/entropy.rb'
434-
- 'lib/zxcvbn/feedback.rb'
435-
- 'lib/zxcvbn/feedback_giver.rb'
436-
- 'lib/zxcvbn/match.rb'
437-
- 'lib/zxcvbn/matchers/date.rb'
438-
- 'lib/zxcvbn/matchers/dictionary.rb'
439-
- 'lib/zxcvbn/matchers/digits.rb'
440-
- 'lib/zxcvbn/matchers/l33t.rb'
441-
- 'lib/zxcvbn/matchers/new_l33t.rb'
442-
- 'lib/zxcvbn/matchers/regex_helpers.rb'
443-
- 'lib/zxcvbn/matchers/repeat.rb'
444-
- 'lib/zxcvbn/matchers/sequences.rb'
445-
- 'lib/zxcvbn/matchers/spatial.rb'
446-
- 'lib/zxcvbn/matchers/year.rb'
447-
- 'lib/zxcvbn/math.rb'
448-
- 'lib/zxcvbn/omnimatch.rb'
449-
- 'lib/zxcvbn/password_strength.rb'
450-
- 'lib/zxcvbn/score.rb'
451-
- 'lib/zxcvbn/scorer.rb'
452-
- 'spec/dictionary_ranker_spec.rb'
453-
- 'spec/feedback_giver_spec.rb'
454-
- 'spec/matchers/date_spec.rb'
455-
- 'spec/matchers/digits_spec.rb'
456-
- 'spec/matchers/l33t_spec.rb'
457-
- 'spec/matchers/repeat_spec.rb'
458-
- 'spec/matchers/sequences_spec.rb'
459-
- 'spec/matchers/spatial_spec.rb'
460-
- 'spec/matchers/year_spec.rb'
461-
- 'spec/omnimatch_spec.rb'
462-
- 'spec/scorer_spec.rb'
463-
- 'spec/scoring/crack_time_spec.rb'
464-
- 'spec/scoring/entropy_spec.rb'
465-
- 'spec/scoring/math_spec.rb'
466-
- 'spec/spec_helper.rb'
467-
- 'spec/support/js_helpers.rb'
468-
- 'spec/support/matcher.rb'
469-
- 'spec/zxcvbn_spec.rb'
470-
- 'zxcvbn-ruby.gemspec'
471-
472255
# Configuration parameters: AllowedVariables.
473256
Style/GlobalVars:
474257
Exclude:

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9-
[Unreleased]: https://github.com/envato/zxcvbn-ruby/compare/v1.2.1...HEAD
9+
[Unreleased]: https://github.com/envato/zxcvbn-ruby/compare/v1.2.2...HEAD
10+
11+
## [1.2.2] - 2025-12-06
12+
13+
### Changed
14+
- Address layout and frozen string literal issues ([#49])
15+
16+
[1.2.2]: https://github.com/envato/zxcvbn-ruby/compare/v1.2.1...v.1.2.2
17+
[#49]: https://github.com/envato/zxcvbn-ruby/pull/49
1018

1119
## [1.2.1] - 2025-12-05
1220

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec

Guardfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
guard :bundler do
24
require 'guard/bundler'
35
require 'guard/bundler/verify'

Rakefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env rake
2+
# frozen_string_literal: true
3+
24
require "bundler/gem_tasks"
35
require "bundler/setup"
46
require 'rspec/core/rake_task'
@@ -20,6 +22,8 @@ task :console do
2022
end
2123

2224
task :compile_coffeescript do
23-
`coffee --compile --bare spec/support/js_source/{matching,scoring,init}.coffee`
24-
`cat spec/support/js_source/{matching,scoring,adjacency_graphs,frequency_lists,init}.js > spec/support/js_source/compiled.js`
25+
system('coffee --compile --bare spec/support/js_source/{matching,scoring,init}.coffee', exception: true)
26+
system(<<~COMMAND.strip, exception: true)
27+
cat spec/support/js_source/{matching,scoring,adjacency_graphs,frequency_lists,init}.js > spec/support/js_source/compiled.js
28+
COMMAND
2529
end

lib/zxcvbn.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'pathname'
24
require 'zxcvbn/version'
35
require 'zxcvbn/tester'

lib/zxcvbn/clock.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Zxcvbn
24
module Clock
35
def self.realtime
@@ -7,4 +9,3 @@ def self.realtime
79
end
810
end
911
end
10-

lib/zxcvbn/crack_time.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Zxcvbn
24
module CrackTime
35
SINGLE_GUESS = 0.010
@@ -6,7 +8,7 @@ module CrackTime
68
SECONDS_PER_GUESS = SINGLE_GUESS / NUM_ATTACKERS
79

810
def entropy_to_crack_time(entropy)
9-
0.5 * (2 ** entropy) * SECONDS_PER_GUESS
11+
0.5 * (2**entropy) * SECONDS_PER_GUESS
1012
end
1113

1214
def crack_time_to_score(seconds)
@@ -50,4 +52,4 @@ def display_time(seconds)
5052
end
5153
end
5254
end
53-
end
55+
end

lib/zxcvbn/data.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
# frozen_string_literal: true
2+
13
require 'json'
24
require 'zxcvbn/dictionary_ranker'
35

46
module Zxcvbn
57
class Data
68
def initialize
79
@ranked_dictionaries = DictionaryRanker.rank_dictionaries(
8-
"english" => read_word_list("english.txt"),
10+
"english" => read_word_list("english.txt"),
911
"female_names" => read_word_list("female_names.txt"),
10-
"male_names" => read_word_list("male_names.txt"),
11-
"passwords" => read_word_list("passwords.txt"),
12-
"surnames" => read_word_list("surnames.txt")
12+
"male_names" => read_word_list("male_names.txt"),
13+
"passwords" => read_word_list("passwords.txt"),
14+
"surnames" => read_word_list("surnames.txt")
1315
)
1416
@adjacency_graphs = JSON.load(DATA_PATH.join('adjacency_graphs.json').read)
1517
end

lib/zxcvbn/dictionary_ranker.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
module Zxcvbn
24
class DictionaryRanker
35
def self.rank_dictionaries(lists)

0 commit comments

Comments
 (0)