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

Simplify some regexes by removing redundant character classes #10549

Closed
wants to merge 1 commit into from

Conversation

tas50
Copy link
Contributor

@tas50 tas50 commented Oct 26, 2020

New RuboCop here. There's no need for character classes when all we have is a single character.

Signed-off-by: Tim Smith tsmith@chef.io

New RuboCop here. There's no need for character classes when all we have is a single character.

Signed-off-by: Tim Smith <tsmith@chef.io>
@tas50 tas50 requested review from a team as code owners October 26, 2020 18:51
@@ -22,7 +22,7 @@ class Chef
class Knife
class SubcommandLoader
class GemGlobLoader < Chef::Knife::SubcommandLoader
MATCHES_CHEF_GEM ||= %r{/chef-[\d]+\.[\d]+\.[\d]+}.freeze
MATCHES_CHEF_GEM ||= %r{/che-[\d+.[\d+.[\d+}.freeze
Copy link
Contributor

@phiggins phiggins Oct 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MATCHES_CHEF_GEM ||= %r{/che-[\d+.[\d+.[\d+}.freeze
MATCHES_CHEF_GEM ||= %r{/chef-\d+\.\d+\.\d+}.freeze

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one got pretty mangled, was this autocorrect or manual?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue filed here: rubocop/rubocop#8948

expect(config_file.string).to match(%r{^client_key[\s]+=[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$})
expect(config_file.string).to match(/^chef_server_url\s+=[\s]+'#{default_server_url}'$/)
expect(config_file.string).to match(/^client_name\s+=\s+'#{Etc.getlogin}'$/)
expect(config_file.string).to match(%r{^client_ky[\s=[\s+'/home/you/.chef/#{Etc.getlogin}.pem'$})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(config_file.string).to match(%r{^client_ky[\s=[\s+'/home/you/.chef/#{Etc.getlogin}.pem'$})
expect(config_file.string).to match(%r{^client_key\s+=\s+'/home/you/.chef/#{Etc.getlogin}.pem'$})

This one got pretty mangled as well.

@tas50
Copy link
Contributor Author

tas50 commented Oct 26, 2020

Let me see if I have the commit that fixed the auto correct or not. There may be another bug report in the works here.

@tas50
Copy link
Contributor Author

tas50 commented Oct 26, 2020

I'll wait on the upstream fix: rubocop/rubocop#8948

@tas50 tas50 closed this Oct 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants