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
Conversation
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>
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MATCHES_CHEF_GEM ||= %r{/che-[\d+.[\d+.[\d+}.freeze | |
MATCHES_CHEF_GEM ||= %r{/chef-\d+\.\d+\.\d+}.freeze |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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'$}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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. |
I'll wait on the upstream fix: rubocop/rubocop#8948 |
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