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

Fix rubocop after disabling BooleanSymbol cop #271

Merged
merged 2 commits into from
Dec 1, 2021
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
16 changes: 8 additions & 8 deletions lib/puppet/provider/grafana_datasource/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def datasources
password: datasource['password'],
database: datasource['database'],
access_mode: datasource['access'],
is_default: datasource['isDefault'] ? true : false,
with_credentials: datasource['withCredentials'] ? true : false,
basic_auth: datasource['basicAuth'] ? true : false,
is_default: datasource['isDefault'] ? :true : :false,
with_credentials: datasource['withCredentials'] ? :true : :false,
basic_auth: datasource['basicAuth'] ? :true : :false,
basic_auth_user: datasource['basicAuthUser'],
basic_auth_password: datasource['basicAuthPassword'],
json_data: datasource['jsonData'],
Expand Down Expand Up @@ -147,7 +147,7 @@ def password=(value)
save_datasource
end

# rubocop:disable Naming/PredicateName
# rubocop:disable Style/PredicateName
Copy link
Member Author

Choose a reason for hiding this comment

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

For these rubocop complains although autofix changed them?

Copy link
Member

Choose a reason for hiding this comment

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

what did it complain about? In an older rubocop version it was in the Naming namespace and the cop got moved to Style (or the other way around).

Copy link
Member Author

Choose a reason for hiding this comment

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

def is_default
datasource[:is_default]
end
Expand All @@ -156,7 +156,7 @@ def is_default=(value)
resource[:is_default] = value
save_datasource
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Style/PredicateName

def basic_auth
datasource[:basic_auth]
Expand Down Expand Up @@ -225,11 +225,11 @@ def save_datasource
database: resource[:database],
user: resource[:user],
password: resource[:password],
isDefault: (resource[:is_default] == true),
basicAuth: (resource[:basic_auth] == true),
isDefault: (resource[:is_default] == :true),
basicAuth: (resource[:basic_auth] == :true),
basicAuthUser: resource[:basic_auth_user],
basicAuthPassword: resource[:basic_auth_password],
withCredentials: (resource[:with_credentials] == true),
withCredentials: (resource[:with_credentials] == :true),
jsonData: resource[:json_data],
secureJsonData: resource[:secure_json_data]
}
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet/provider/grafana_notification/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ def notifications
id: notification['id'],
name: notification['name'],
type: notification['type'],
is_default: notification['isDefault'] ? true : false,
send_reminder: notification['sendReminder'] ? true : false,
is_default: notification['isDefault'] ? :true : :false,
send_reminder: notification['sendReminder'] ? :true : :false,
frequency: notification['frequency'],
settings: notification['settings']
}
Expand All @@ -59,7 +59,7 @@ def type=(value)
save_notification
end

# rubocop:disable Naming/PredicateName
# rubocop:disable Style/PredicateName
def is_default
notification[:is_default]
end
Expand All @@ -77,7 +77,7 @@ def send_reminder=(value)
resource[:send_reminder] = value
save_notification
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Style/PredicateName

def frequency
notification[:frequency]
Expand All @@ -101,8 +101,8 @@ def save_notification
data = {
name: resource[:name],
type: resource[:type],
isDefault: (resource[:is_default] == true),
sendReminder: (resource[:send_reminder] == true),
isDefault: (resource[:is_default] == :true),
sendReminder: (resource[:send_reminder] == :true),
frequency: resource[:frequency],
settings: resource[:settings]
}
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/provider/grafana_user/grafana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def users
email: user['email'],
theme: user['theme'],
password: nil,
is_admin: user['isGrafanaAdmin'] ? true : false
is_admin: user['isGrafanaAdmin'] ? :true : :false
}
end
rescue JSON::ParserError
Expand Down Expand Up @@ -88,7 +88,7 @@ def password=(value)
save_user
end

# rubocop:disable Naming/PredicateName
# rubocop:disable Style/PredicateName
def is_admin
user[:is_admin]
end
Expand All @@ -97,7 +97,7 @@ def is_admin=(value)
resource[:is_admin] = value
save_user
end
# rubocop:enable Naming/PredicateName
# rubocop:enable Style/PredicateName

def save_user
data = {
Expand All @@ -106,7 +106,7 @@ def save_user
email: resource[:email],
password: resource[:password],
theme: resource[:theme],
isGrafanaAdmin: (resource[:is_admin] == true)
isGrafanaAdmin: (resource[:is_admin] == :true)
}

if user.nil?
Expand Down
12 changes: 6 additions & 6 deletions lib/puppet/type/grafana_datasource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@

newproperty(:is_default) do
desc 'Whether the datasource is the default one'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:basic_auth) do
desc 'Whether basic auth is enabled or not'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:basic_auth_user) do
Expand All @@ -93,8 +93,8 @@

newproperty(:with_credentials) do
desc 'Whether credentials such as cookies or auth headers should be sent with cross-site requests'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:json_data) do
Expand Down
8 changes: 4 additions & 4 deletions lib/puppet/type/grafana_notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@

newproperty(:is_default) do
desc 'Whether the notification is the default one'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:send_reminder) do
desc 'Whether automatic message resending is enabled or not'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

newproperty(:frequency) do
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/type/grafana_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def insync?(_is) # rubocop:disable Naming/MethodParameterName

newproperty(:is_admin) do
desc 'Whether the user is a grafana admin'
newvalues(true, false)
defaultto false
newvalues(:true, :false)
defaultto :false
end

def set_sensitive_parameters(sensitive_parameters) # rubocop:disable Naming/AccessorMethodName
def set_sensitive_parameters(sensitive_parameters) # rubocop:disable Style/AccessorMethodName
parameter(:password).sensitive = true if parameter(:password)
super(sensitive_parameters)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/classes/grafana_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
describe 'create data_dir' do
it { is_expected.to contain_file('/var/lib/grafana').with_ensure('directory') }
end
when 'FreBSD'
when 'FreeBSD'
Copy link
Member

Choose a reason for hiding this comment

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

ah lol

Copy link
Member Author

Choose a reason for hiding this comment

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

😄

describe 'create data_dir' do
it { is_expected.to contain_file('/var/db/grafana').with_ensure('directory') }
end
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/puppet/type/grafana_datasource_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
expect(gdatasource[:type]).to eq('elasticsearch')
expect(gdatasource[:organization]).to eq('test_org')
expect(gdatasource[:access_mode]).to eq(:proxy)
expect(gdatasource[:is_default]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gdatasource[:basic_auth]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gdatasource[:is_default]).to eq(:true)
expect(gdatasource[:basic_auth]).to eq(:true)
expect(gdatasource[:basic_auth_user]).to eq('user')
expect(gdatasource[:basic_auth_password]).to eq('password')
expect(gdatasource[:with_credentials]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gdatasource[:with_credentials]).to eq(:true)
expect(gdatasource[:database]).to eq('test_db')
expect(gdatasource[:user]).to eq('db_user')
expect(gdatasource[:password]).to eq('db_password')
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/puppet/type/grafana_notification_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
expect(gnotification[:name]).to eq('foo')
expect(gnotification[:grafana_url]).to eq('http://example.com')
expect(gnotification[:type]).to eq('email')
expect(gnotification[:is_default]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gnotification[:send_reminder]).to eq(:true) # rubocop:disable Lint/BooleanSymbol
expect(gnotification[:is_default]).to eq(:true)
expect(gnotification[:send_reminder]).to eq(:true)
expect(gnotification[:frequency]).to eq('20m')
expect(gnotification[:settings]).to eq(adresses: 'test@example.com')
end
Expand Down