Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3261 coding style regexp #3263

Merged
merged 2 commits into from
Sep 26, 2024
Merged
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
10 changes: 9 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ Style/FrozenStringLiteralComment:
Layout/LineLength:
Enabled: false

# We do not enforce the cop in the models as it would not work with the
# DSL style of the models
Lint/AmbiguousRegexpLiteral:
Enabled: false
Enabled: true
Exclude:
- lib/oxidized/model/*.rb

Lint/RaiseException:
Enabled: true
Expand Down Expand Up @@ -61,6 +65,10 @@ Style/HashTransformKeys:
Style/HashTransformValues:
Enabled: true

Style/RegexpLiteral:
EnforcedStyle: slashes
AllowInnerSlashes: true

Style/RescueModifier:
Enabled: false

Expand Down
11 changes: 2 additions & 9 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-07-05 13:13:46 UTC using RuboCop version 1.64.1.
# on 2024-09-10 07:42:30 UTC using RuboCop version 1.65.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand Down Expand Up @@ -72,19 +72,12 @@ Style/OpenStructUse:
- 'lib/oxidized/node.rb'
- 'spec/hook/githubrepo_spec.rb'

# Offense count: 48
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
# SupportedStyles: slashes, percent_r, mixed
Style/RegexpLiteral:
Enabled: false

# Offense count: 31
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/SlicingWithRange:
Enabled: false

# Offense count: 83
# Offense count: 84
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: Mode.
Style/StringConcatenation:
Expand Down
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ task :test do
Rake::TestTask.new do |t|
t.libs << 'spec'
t.test_files = FileList['spec/**/*_spec.rb']
t.warning = true
# Don't display ambiguity warning between regexp and division in models
t.warning = false
t.verbose = true
end
end
Expand Down Expand Up @@ -75,7 +76,7 @@ task :chmod do
extra/update-ca-certificates.runit
]
dirs = []
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }.each do |file|
%x(git ls-files -z).split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }.each do |file|
dirs.push(File.dirname(file))
xbit.include?(file) ? File.chmod(0o0755, file) : File.chmod(0o0644, file)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/oxidized/model/aosw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class AOSW < Oxidized::Model

comment '# '
# see /spec/model/aosw_spec.rb for prompt examples
prompt(/^\(?[\w\:.@-]+\)? ?[*^]?(\[[\w\/]+\] ?)?[#>] ?$/)
prompt /^\(?[\w\:.@-]+\)? ?[*^]?(\[[\w\/]+\] ?)?[#>] ?$/

# Ignore cariage returns - also for the prompt
expect "\r" do |data, re|
Expand Down
4 changes: 2 additions & 2 deletions lib/oxidized/model/garderos.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ class Garderos < Oxidized::Model

# remove all ANSI escape codes, as GRS uses them :-(
# the prompt does not need to match escape codes, as they have been removed
expect %r{\e\[\d*m\r?} do |data, re|
expect /\e\[\d*m\r?/ do |data, re|
data.gsub re, ''
end

prompt %r{[\w-]+# }
prompt /[\w-]+# /
comment '# '

cmd :all do |cfg|
Expand Down
2 changes: 1 addition & 1 deletion lib/oxidized/model/nodegrid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Nodegrid < Oxidized::Model
# ZPE Nodegrid (Tested with Nodegrid Gate/Bold/NSR)
# https://www.zpesystems.com/products/

prompt(%r{(?<!@)\[(.*?\s/)\]#})
prompt /(?<!@)\[(.*?\s\/)\]#/
comment '# '

cmd 'show system/about/' do |cfg|
Expand Down
2 changes: 1 addition & 1 deletion oxidized.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.summary = 'feeble attempt at rancid'
s.description = 'software to fetch configuration from network devices and store them'
s.rubyforge_project = s.name
s.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
s.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(/^(test|spec|features)\//) }
s.executables = %w[oxidized]
s.require_path = 'lib'

Expand Down
Loading