Skip to content

Commit 28e0f94

Browse files
committed
Lint/BooleanSymbol
Boolean symbols are used to workaround a bug in puppet's type DSL that prevents falsey properties from being managed (PUP-2368). In general this enables the cop, but excludes specific files and lines where symbols are needed.
1 parent 6bb7b79 commit 28e0f94

File tree

5 files changed

+15
-8
lines changed

5 files changed

+15
-8
lines changed

.rubocop.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ AllCops:
1717
- 'lib/puppet/vendor/**/*'
1818
- 'lib/puppet/pops/parser/eparser.rb'
1919

20+
# puppet uses symbol booleans in types and providers to work around long standing
21+
# bugs when trying to manage falsey pararameters and properties
22+
Lint/BooleanSymbol:
23+
Enabled: true
24+
Exclude:
25+
- 'lib/puppet/type.rb'
26+
- 'lib/puppet/type/**/*.rb'
27+
- 'lib/puppet/provider/**/*.rb'
28+
- 'lib/puppet/reference/providers.rb'
29+
- 'lib/puppet/parameter/value.rb'
30+
2031
Metrics/AbcSize:
2132
Enabled: false
2233

.rubocop_todo.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,10 +580,6 @@ Layout/TrailingEmptyLines:
580580
Layout/TrailingWhitespace:
581581
Enabled: false
582582

583-
# This cop supports safe auto-correction (--auto-correct).
584-
Lint/BooleanSymbol:
585-
Enabled: false
586-
587583
# Configuration parameters: AllowedMethods.
588584
# AllowedMethods: enums
589585
Lint/ConstantDefinitionInBlock:

lib/puppet/coercion.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ def self.boolean(value)
1919
end
2020

2121
case value
22-
when true, :true, 'true', :yes, 'yes'
22+
when true, :true, 'true', :yes, 'yes' # rubocop:disable Lint/BooleanSymbol
2323
true
24-
when false, :false, 'false', :no, 'no'
24+
when false, :false, 'false', :no, 'no' # rubocop:disable Lint/BooleanSymbol
2525
false
2626
else
2727
fail('expected a boolean value')

lib/puppet/configurer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ def valid_server_environment?
528528
session = Puppet.lookup(:http_session)
529529
begin
530530
fs = session.route_to(:fileserver)
531-
fs.get_file_metadatas(path: URI(Puppet[:pluginsource]).path, recurse: :false, environment: @environment)
531+
fs.get_file_metadatas(path: URI(Puppet[:pluginsource]).path, recurse: :false, environment: @environment) # rubocop:disable Lint/BooleanSymbol
532532
true
533533
rescue Puppet::HTTP::ResponseError => detail
534534
if detail.response.code == 404

lib/puppet/http/service/file_server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def get_file_metadata(path:, environment:, links: :manage, checksum_type: Puppet
9999
#
100100
# @api public
101101
#
102-
def get_file_metadatas(path: nil, environment:, recurse: :false, recurselimit: nil, max_files: nil, ignore: nil, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore)
102+
def get_file_metadatas(path: nil, environment:, recurse: :false, recurselimit: nil, max_files: nil, ignore: nil, links: :manage, checksum_type: Puppet[:digest_algorithm], source_permissions: :ignore) # rubocop:disable Lint/BooleanSymbol
103103
validate_path(path)
104104

105105
headers = add_puppet_headers('Accept' => get_mime_types(Puppet::FileServing::Metadata).join(', '))

0 commit comments

Comments
 (0)