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

MODULES-5690: Implementing Rubocop in the module #418

Merged
merged 1 commit into from Oct 17, 2017
Merged

MODULES-5690: Implementing Rubocop in the module #418

merged 1 commit into from Oct 17, 2017

Conversation

david22swan
Copy link
Member

No description provided.

when 'AIX'
servicename = 'xntpd'
else
servicename = if fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12'
Copy link
Contributor

Choose a reason for hiding this comment

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

nice !

when '5.11'
packagename = 'service/network/ntp'
end
else
if fact('operatingsystem') == 'SLES' and fact('operatingsystemmajrelease') == '12'
servicename = 'ntpd'
if fact('operatingsystem') == 'SLES' && fact('operatingsystemmajrelease') == '12'
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like servicename will not be set for solaris

Copy link
Contributor

@pmcmaw pmcmaw left a comment

Choose a reason for hiding this comment

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

2 minor changes but class work @david22swan!

.travis.yml:
extras:
- rvm: 2.1.9
script: bundle exec rake rubocop
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to remove this line break.

Copy link
Member Author

Choose a reason for hiding this comment

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

Understand now, have resolved

Copy link
Contributor

Choose a reason for hiding this comment

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

Have you pushed this change? I can still see it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect

@@ -13,4 +13,5 @@
begin
require 'spec_helper_local'
rescue LoadError
puts 'Rescue Load Error'
end
Copy link
Contributor

Choose a reason for hiding this comment

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

All changes in this file should probably be done in Module Sync rather than in the actual file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't know that.
Was brought up as a rubocop error so I changed it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fix has been made to modulesync

@tphoney
Copy link
Contributor

tphoney commented Oct 11, 2017

@david22swan i am happy with this, due to the large number of changes it would be great if @hunner @HAIL9000 or @eputnam could look as well.

@david22swan
Copy link
Member Author

Ok

when '5.11'
packagename = 'service/network/ntp'
end
else
if fact('operatingsystem') == 'SLES' and fact('operatingsystemmajrelease') == '12'
Copy link
Contributor

Choose a reason for hiding this comment

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

Did the sles conditional get re-added somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

To my knowledge this peace of code did not seem to do anything at all, and seemed to be a remnant of something from earlier.

end
end

describe 'keys' do
it 'enables the key parameters' do
pp = <<-EOS
pp = <<-EOS
Copy link
Contributor

@hunner hunner Oct 11, 2017

Choose a reason for hiding this comment

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

I think this should be a let(:pp) block if it's outside of the it but used inside of the it. See http://www.betterspecs.org/#let and referenced stackoverflow link.

Copy link
Member Author

Choose a reason for hiding this comment

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

Have made the change, though a little unsure of why it was necesary

end
end

describe 'package' do
it 'installs the right package' do
pp = <<-EOS
pp = <<-EOS
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto

describe 'ntp class:', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
it 'should run successfully' do
describe 'ntp class:', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
context 'ntp' do
pp = "class { 'ntp': }"
Copy link
Contributor

@hunner hunner Oct 11, 2017

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member Author

Choose a reason for hiding this comment

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

There's no actual explanation to ditto?

Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops weird... github was missing some comments and put them out of order, but I guess I didn't fix it right... this is what the first was supposed to say:

I think this should be a let(:pp) block if it's outside of the it but used inside of the it. See http://www.betterspecs.org/#let and referenced stackoverflow link.


describe "ntp class with disable_monitor:", :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
describe 'ntp class with disable_monitor:', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
context 'should disable' do
pp = "class { 'ntp': disable_monitor => true }"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto, even though this was pre-existing.


describe 'service is unmanaged' do
it 'shouldnt stop the service' do
describe 'service is unmanaged' do
pp = <<-EOS
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

it 'should be stopped' do
expect(output.stdout).to match(/Active\:\s+inactive/)
# HACK: until we either update SpecInfra or come up with alternative
output = shell('service ntpd status', acceptable_exit_codes: [0, 3])
Copy link
Contributor

Choose a reason for hiding this comment

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

Ugh. I think this should be a let block as well. That way the execution is delayed until it's actually referenced. I understand that this isn't part of rubocop/style changes though.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done


describe 'preferred servers', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
describe 'preferred servers', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
pp = <<-EOS
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto, even though this was pre-existing.

context 'should run successfully' do
pp = "class { 'ntp': restrict => ['test restrict']}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto

context 'should run successfully' do
pp = "class { 'ntp': statistics => ['loopstats'], disable_monitor => false}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Member Author

Choose a reason for hiding this comment

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

ditto

@david22swan
Copy link
Member Author

Ok.
Have put let blocks around majority of variables that were requested by @hunner.
Had to remove blocks around '<<-EOS EOS' blocks as it seemed to confuse Rubocop

@hunner hunner merged commit 13069d5 into puppetlabs:master Oct 17, 2017
hunner added a commit that referenced this pull request Oct 17, 2017
MODULES-5690: Implementing Rubocop in the module
@david22swan david22swan deleted the MODULES-5690 branch October 18, 2017 08:59
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

4 participants