puppet-lint 3.4.0 → 4.0.0.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/puppet-lint/bin.rb +7 -11
- data/lib/puppet-lint/checkplugin.rb +4 -8
- data/lib/puppet-lint/checks.rb +7 -9
- data/lib/puppet-lint/configuration.rb +2 -2
- data/lib/puppet-lint/data.rb +35 -39
- data/lib/puppet-lint/lexer/string_slurper.rb +2 -3
- data/lib/puppet-lint/lexer/token.rb +6 -5
- data/lib/puppet-lint/lexer.rb +35 -38
- data/lib/puppet-lint/monkeypatches.rb +4 -4
- data/lib/puppet-lint/optparser.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/arrow_on_right_operand_line.rb +1 -0
- data/lib/puppet-lint/plugins/check_classes/autoloader_layout.rb +2 -4
- data/lib/puppet-lint/plugins/check_classes/class_inherits_from_params_class.rb +2 -2
- data/lib/puppet-lint/plugins/check_classes/code_on_top_scope.rb +1 -1
- data/lib/puppet-lint/plugins/check_classes/nested_classes_or_defines.rb +5 -5
- data/lib/puppet-lint/plugins/check_classes/parameter_order.rb +8 -9
- data/lib/puppet-lint/plugins/check_classes/variable_scope.rb +32 -34
- data/lib/puppet-lint/plugins/check_conditionals/case_without_default.rb +2 -2
- data/lib/puppet-lint/plugins/check_documentation/documentation.rb +7 -6
- data/lib/puppet-lint/plugins/check_nodes/unquoted_node_name.rb +1 -1
- data/lib/puppet-lint/plugins/check_resources/ensure_first_param.rb +3 -5
- data/lib/puppet-lint/plugins/check_resources/ensure_not_symlink_target.rb +2 -2
- data/lib/puppet-lint/plugins/check_resources/file_mode.rb +6 -6
- data/lib/puppet-lint/plugins/check_resources/unquoted_file_mode.rb +4 -4
- data/lib/puppet-lint/plugins/check_strings/double_quoted_strings.rb +4 -4
- data/lib/puppet-lint/plugins/check_strings/only_variable_string.rb +4 -5
- data/lib/puppet-lint/plugins/check_strings/quoted_booleans.rb +4 -4
- data/lib/puppet-lint/plugins/check_strings/single_quote_string_with_variables.rb +2 -2
- data/lib/puppet-lint/plugins/check_strings/variables_not_enclosed.rb +8 -7
- data/lib/puppet-lint/plugins/check_variables/variable_contains_dash.rb +3 -3
- data/lib/puppet-lint/plugins/check_variables/variable_is_lowercase.rb +2 -2
- data/lib/puppet-lint/plugins/check_whitespace/140chars.rb +1 -0
- data/lib/puppet-lint/plugins/check_whitespace/80chars.rb +2 -1
- data/lib/puppet-lint/plugins/check_whitespace/arrow_alignment.rb +9 -9
- data/lib/puppet-lint/plugins/check_whitespace/hard_tabs.rb +2 -2
- data/lib/puppet-lint/plugins/check_whitespace/line_length.rb +6 -6
- data/lib/puppet-lint/plugins/legacy_facts/legacy_facts.rb +106 -105
- data/lib/puppet-lint/plugins/top_scope_facts/top_scope_facts.rb +3 -2
- data/lib/puppet-lint/plugins.rb +3 -4
- data/lib/puppet-lint/report/codeclimate.rb +3 -2
- data/lib/puppet-lint/report/github.rb +1 -0
- data/lib/puppet-lint/tasks/puppet-lint.rb +7 -26
- data/lib/puppet-lint/tasks/release_test.rb +4 -4
- data/lib/puppet-lint/version.rb +1 -1
- data/lib/puppet-lint.rb +5 -3
- data/rubocop_baseline.yml +3 -440
- data/spec/spec_helper.rb +3 -2
- data/spec/spec_helper_acceptance_local.rb +1 -1
- data/spec/unit/puppet-lint/bin_spec.rb +12 -2
- data/spec/unit/puppet-lint/configuration_spec.rb +14 -14
- data/spec/unit/puppet-lint/lexer/string_slurper_spec.rb +3 -5
- data/spec/unit/puppet-lint/lexer_spec.rb +10 -11
- data/spec/unit/puppet-lint/plugins/check_classes/parameter_order_spec.rb +2 -2
- data/spec/unit/puppet-lint/plugins/check_conditionals/case_without_default_spec.rb +5 -5
- data/spec/unit/puppet-lint/plugins/check_strings/double_quoted_strings_spec.rb +1 -1
- data/spec/unit/puppet-lint/plugins/check_strings/only_variable_string_spec.rb +1 -1
- data/spec/unit/puppet-lint/plugins/check_whitespace/140chars_spec.rb +0 -2
- data/spec/unit/puppet-lint/plugins/check_whitespace/80chars_spec.rb +1 -3
- data/spec/unit/puppet-lint/plugins/legacy_facts/legacy_facts_spec.rb +16 -0
- data/spec/unit/puppet-lint/plugins/top_scope_facts/top_scope_facts_spec.rb +1 -0
- metadata +5 -5
@@ -6,111 +6,111 @@
|
|
6
6
|
#
|
7
7
|
# This plugin was adopted in to puppet-lint from https://github.com/mmckinst/puppet-lint-legacy_facts-check
|
8
8
|
# Thanks to @mmckinst, @seanmil, @rodjek, @baurmatt, @bart2 and @joshcooper for the original work.
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
].freeze
|
9
|
+
LEGACY_FACTS_VAR_TYPES = Set[:VARIABLE, :UNENC_VARIABLE]
|
10
|
+
|
11
|
+
# These facts that can't be converted to new facts.
|
12
|
+
UNCONVERTIBLE_FACTS = ['memoryfree_mb', 'memorysize_mb', 'swapfree_mb',
|
13
|
+
'swapsize_mb', 'blockdevices', 'interfaces', 'zones',
|
14
|
+
'sshfp_dsa', 'sshfp_ecdsa', 'sshfp_ed25519',
|
15
|
+
'sshfp_rsa'].freeze
|
16
|
+
|
17
|
+
# These facts will depend on how a system is set up and can't just be
|
18
|
+
# enumerated like the EASY_FACTS below.
|
19
|
+
#
|
20
|
+
# For example a server might have two block devices named 'sda' and 'sdb' so
|
21
|
+
# there would be a $blockdeivce_sda_vendor and $blockdeivce_sdb_vendor fact
|
22
|
+
# for each device. Or it could have 26 block devices going all the way up to
|
23
|
+
# 'sdz'. There is no way to know what the possibilities are so we have to use
|
24
|
+
# a regex to match them.
|
25
|
+
REGEX_FACTS = [%r{^blockdevice_(?<devicename>.*)_(?<attribute>model|size|vendor)$},
|
26
|
+
%r{^(?<attribute>ipaddress|ipaddress6|macaddress|mtu|netmask|netmask6|network|network6)_(?<interface>.*)$},
|
27
|
+
%r{^processor(?<id>[0-9]+)$},
|
28
|
+
%r{^sp_(?<name>.*)$},
|
29
|
+
%r{^ssh(?<algorithm>dsa|ecdsa|ed25519|rsa)key$},
|
30
|
+
%r{^ldom_(?<name>.*)$},
|
31
|
+
%r{^zone_(?<name>.*)_(?<attribute>brand|iptype|name|uuid|id|path|status)$}].freeze
|
32
|
+
|
33
|
+
# These facts have a one to one correlation between a legacy fact and a new
|
34
|
+
# structured fact.
|
35
|
+
EASY_FACTS = {
|
36
|
+
'architecture' => "facts['os']['architecture']",
|
37
|
+
'augeasversion' => "facts['augeas']['version']",
|
38
|
+
'bios_release_date' => "facts['dmi']['bios']['release_date']",
|
39
|
+
'bios_vendor' => "facts['dmi']['bios']['vendor']",
|
40
|
+
'bios_version' => "facts['dmi']['bios']['version']",
|
41
|
+
'boardassettag' => "facts['dmi']['board']['asset_tag']",
|
42
|
+
'boardmanufacturer' => "facts['dmi']['board']['manufacturer']",
|
43
|
+
'boardproductname' => "facts['dmi']['board']['product']",
|
44
|
+
'boardserialnumber' => "facts['dmi']['board']['serial_number']",
|
45
|
+
'chassisassettag' => "facts['dmi']['chassis']['asset_tag']",
|
46
|
+
'chassistype' => "facts['dmi']['chassis']['type']",
|
47
|
+
'domain' => "facts['networking']['domain']",
|
48
|
+
'fqdn' => "facts['networking']['fqdn']",
|
49
|
+
'gid' => "facts['identity']['group']",
|
50
|
+
'hardwareisa' => "facts['processors']['isa']",
|
51
|
+
'hardwaremodel' => "facts['os']['hardware']",
|
52
|
+
'hostname' => "facts['networking']['hostname']",
|
53
|
+
'id' => "facts['identity']['user']",
|
54
|
+
'ipaddress' => "facts['networking']['ip']",
|
55
|
+
'ipaddress6' => "facts['networking']['ip6']",
|
56
|
+
'lsbdistcodename' => "facts['os']['distro']['codename']",
|
57
|
+
'lsbdistdescription' => "facts['os']['distro']['description']",
|
58
|
+
'lsbdistid' => "facts['os']['distro']['id']",
|
59
|
+
'lsbdistrelease' => "facts['os']['distro']['release']['full']",
|
60
|
+
'lsbmajdistrelease' => "facts['os']['distro']['release']['major']",
|
61
|
+
'lsbminordistrelease' => "facts['os']['distro']['release']['minor']",
|
62
|
+
'lsbrelease' => "facts['os']['distro']['release']['specification']",
|
63
|
+
'macaddress' => "facts['networking']['mac']",
|
64
|
+
'macosx_buildversion' => "facts['os']['macosx']['build']",
|
65
|
+
'macosx_productname' => "facts['os']['macosx']['product']",
|
66
|
+
'macosx_productversion' => "facts['os']['macosx']['version']['full']",
|
67
|
+
'macosx_productversion_major' => "facts['os']['macosx']['version']['major']",
|
68
|
+
'macosx_productversion_minor' => "facts['os']['macosx']['version']['minor']",
|
69
|
+
'manufacturer' => "facts['dmi']['manufacturer']",
|
70
|
+
'memoryfree' => "facts['memory']['system']['available']",
|
71
|
+
'memorysize' => "facts['memory']['system']['total']",
|
72
|
+
'netmask' => "facts['networking']['netmask']",
|
73
|
+
'netmask6' => "facts['networking']['netmask6']",
|
74
|
+
'network' => "facts['networking']['network']",
|
75
|
+
'network6' => "facts['networking']['network6']",
|
76
|
+
'operatingsystem' => "facts['os']['name']",
|
77
|
+
'operatingsystemmajrelease' => "facts['os']['release']['major']",
|
78
|
+
'operatingsystemrelease' => "facts['os']['release']['full']",
|
79
|
+
'osfamily' => "facts['os']['family']",
|
80
|
+
'physicalprocessorcount' => "facts['processors']['physicalcount']",
|
81
|
+
'processorcount' => "facts['processors']['count']",
|
82
|
+
'productname' => "facts['dmi']['product']['name']",
|
83
|
+
'rubyplatform' => "facts['ruby']['platform']",
|
84
|
+
'rubysitedir' => "facts['ruby']['sitedir']",
|
85
|
+
'rubyversion' => "facts['ruby']['version']",
|
86
|
+
'selinux' => "facts['os']['selinux']['enabled']",
|
87
|
+
'selinux_config_mode' => "facts['os']['selinux']['config_mode']",
|
88
|
+
'selinux_config_policy' => "facts['os']['selinux']['config_policy']",
|
89
|
+
'selinux_current_mode' => "facts['os']['selinux']['current_mode']",
|
90
|
+
'selinux_enforced' => "facts['os']['selinux']['enforced']",
|
91
|
+
'selinux_policyversion' => "facts['os']['selinux']['policy_version']",
|
92
|
+
'serialnumber' => "facts['dmi']['product']['serial_number']",
|
93
|
+
'swapencrypted' => "facts['memory']['swap']['encrypted']",
|
94
|
+
'swapfree' => "facts['memory']['swap']['available']",
|
95
|
+
'swapsize' => "facts['memory']['swap']['total']",
|
96
|
+
'system32' => "facts['os']['windows']['system32']",
|
97
|
+
'uptime' => "facts['system_uptime']['uptime']",
|
98
|
+
'uptime_days' => "facts['system_uptime']['days']",
|
99
|
+
'uptime_hours' => "facts['system_uptime']['hours']",
|
100
|
+
'uptime_seconds' => "facts['system_uptime']['seconds']",
|
101
|
+
'uuid' => "facts['dmi']['product']['uuid']",
|
102
|
+
'xendomains' => "facts['xen']['domains']",
|
103
|
+
'zonename' => "facts['solaris_zones']['current']"
|
104
|
+
}.freeze
|
105
|
+
|
106
|
+
# A list of valid hash key token types
|
107
|
+
HASH_KEY_TYPES = Set[
|
108
|
+
:STRING, # Double quoted string
|
109
|
+
:SSTRING, # Single quoted string
|
110
|
+
:NAME, # Unquoted single word
|
111
|
+
].freeze
|
113
112
|
|
113
|
+
PuppetLint.new_check(:legacy_facts) do
|
114
114
|
def check
|
115
115
|
tokens.select { |x| LEGACY_FACTS_VAR_TYPES.include?(x.type) }.each do |token|
|
116
116
|
fact_name = ''
|
@@ -137,12 +137,13 @@ PuppetLint.new_check(:legacy_facts) do
|
|
137
137
|
end
|
138
138
|
|
139
139
|
next unless EASY_FACTS.include?(fact_name) || UNCONVERTIBLE_FACTS.include?(fact_name) || fact_name.match(Regexp.union(REGEX_FACTS))
|
140
|
+
|
140
141
|
notify :warning, {
|
141
142
|
message: "legacy fact '#{fact_name}'",
|
142
143
|
line: token.line,
|
143
144
|
column: token.column,
|
144
145
|
token: token,
|
145
|
-
fact_name: fact_name
|
146
|
+
fact_name: fact_name
|
146
147
|
}
|
147
148
|
end
|
148
149
|
end
|
@@ -13,8 +13,9 @@
|
|
13
13
|
#
|
14
14
|
# This plugin was adopted in to puppet-lint from https://github.com/mmckinst/puppet-lint-top_scope_facts-check
|
15
15
|
# Thanks to @mmckinst, @seanmil and @alexjfisher for the original work.
|
16
|
+
TOP_SCOPE_FACTS_VAR_TYPES = Set[:VARIABLE, :UNENC_VARIABLE]
|
17
|
+
|
16
18
|
PuppetLint.new_check(:top_scope_facts) do
|
17
|
-
TOP_SCOPE_FACTS_VAR_TYPES = Set[:VARIABLE, :UNENC_VARIABLE]
|
18
19
|
def check
|
19
20
|
whitelist = ['trusted', 'facts'] + (PuppetLint.configuration.top_scope_variables || [])
|
20
21
|
whitelist = whitelist.join('|')
|
@@ -27,7 +28,7 @@ PuppetLint.new_check(:top_scope_facts) do
|
|
27
28
|
message: 'top scope fact instead of facts hash',
|
28
29
|
line: token.line,
|
29
30
|
column: token.column,
|
30
|
-
token: token
|
31
|
+
token: token
|
31
32
|
}
|
32
33
|
end
|
33
34
|
end
|
data/lib/puppet-lint/plugins.rb
CHANGED
@@ -55,9 +55,8 @@ class PuppetLint::Plugins
|
|
55
55
|
def load_prerelease_plugins?
|
56
56
|
# Load prerelease plugins (which ruby defines as any gem which has a letter in its version number).
|
57
57
|
# Can't use puppet-lint configuration object here because this code executes before the command line is parsed.
|
58
|
-
if ENV['PUPPET_LINT_LOAD_PRERELEASE_PLUGINS']
|
59
|
-
|
60
|
-
end
|
58
|
+
return ['true', 'yes'].include?(ENV['PUPPET_LINT_LOAD_PRERELEASE_PLUGINS'].downcase) if ENV['PUPPET_LINT_LOAD_PRERELEASE_PLUGINS']
|
59
|
+
|
61
60
|
false
|
62
61
|
end
|
63
62
|
|
@@ -76,7 +75,7 @@ class PuppetLint::Plugins
|
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
79
|
-
Dir[File.expand_path('plugins/**/*.rb', File.dirname(__FILE__))].each do |file|
|
78
|
+
Dir[File.expand_path('plugins/**/*.rb', File.dirname(__FILE__))].sort.each do |file|
|
80
79
|
require file
|
81
80
|
end
|
82
81
|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'digest'
|
4
4
|
require 'json'
|
5
5
|
|
6
|
+
# rubocop:disable Style/ClassAndModuleChildren
|
6
7
|
class PuppetLint::Report
|
7
8
|
# Formats problems and writes them to a file as a code climate compatible report.
|
8
9
|
class CodeClimateReporter
|
@@ -29,9 +30,9 @@ class PuppetLint::Report
|
|
29
30
|
path: message[:path],
|
30
31
|
lines: {
|
31
32
|
begin: message[:line],
|
32
|
-
end: message[:line]
|
33
|
+
end: message[:line]
|
33
34
|
}
|
34
|
-
}
|
35
|
+
}
|
35
36
|
}
|
36
37
|
|
37
38
|
issue[:fingerprint] = Digest::MD5.hexdigest(Marshal.dump(issue))
|
@@ -12,24 +12,12 @@ require 'puppet-lint/report/codeclimate'
|
|
12
12
|
#
|
13
13
|
# require 'puppet-lint'
|
14
14
|
# PuppetLint::RakeTask.new
|
15
|
-
class PuppetLint::RakeTask <
|
15
|
+
class PuppetLint::RakeTask < Rake::TaskLib
|
16
16
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
17
17
|
|
18
18
|
DEFAULT_PATTERN = '**/*.pp'.freeze
|
19
19
|
|
20
|
-
attr_accessor :name
|
21
|
-
attr_accessor :pattern
|
22
|
-
attr_accessor :ignore_paths
|
23
|
-
attr_accessor :with_filename
|
24
|
-
attr_accessor :disable_checks
|
25
|
-
attr_accessor :only_checks
|
26
|
-
attr_accessor :fail_on_warnings
|
27
|
-
attr_accessor :error_level
|
28
|
-
attr_accessor :log_format
|
29
|
-
attr_accessor :with_context
|
30
|
-
attr_accessor :fix
|
31
|
-
attr_accessor :show_ignored
|
32
|
-
attr_accessor :relative
|
20
|
+
attr_accessor :name, :pattern, :ignore_paths, :with_filename, :disable_checks, :only_checks, :fail_on_warnings, :error_level, :log_format, :with_context, :fix, :show_ignored, :relative
|
33
21
|
|
34
22
|
# Public: Initialise a new PuppetLint::RakeTask.
|
35
23
|
#
|
@@ -80,13 +68,9 @@ class PuppetLint::RakeTask < ::Rake::TaskLib
|
|
80
68
|
PuppetLint.configuration.send("#{config}=".to_sym, value) unless value.nil?
|
81
69
|
end
|
82
70
|
|
83
|
-
if PuppetLint.configuration.ignore_paths && @ignore_paths.empty?
|
84
|
-
@ignore_paths = PuppetLint.configuration.ignore_paths
|
85
|
-
end
|
71
|
+
@ignore_paths = PuppetLint.configuration.ignore_paths if PuppetLint.configuration.ignore_paths && @ignore_paths.empty?
|
86
72
|
|
87
|
-
if PuppetLint.configuration.pattern
|
88
|
-
@pattern = PuppetLint.configuration.pattern
|
89
|
-
end
|
73
|
+
@pattern = PuppetLint.configuration.pattern if PuppetLint.configuration.pattern
|
90
74
|
|
91
75
|
RakeFileUtils.send(:verbose, true) do
|
92
76
|
linter = PuppetLint.new
|
@@ -97,18 +81,15 @@ class PuppetLint::RakeTask < ::Rake::TaskLib
|
|
97
81
|
|
98
82
|
matched_files.to_a.each do |puppet_file|
|
99
83
|
next unless File.file?(puppet_file)
|
84
|
+
|
100
85
|
linter.file = puppet_file
|
101
86
|
linter.run
|
102
87
|
all_problems << linter.print_problems
|
103
88
|
|
104
|
-
if PuppetLint.configuration.fix && linter.problems.none? { |e| e[:check] == :syntax }
|
105
|
-
IO.write(puppet_file, linter.manifest)
|
106
|
-
end
|
89
|
+
File.write(puppet_file, linter.manifest) if PuppetLint.configuration.fix && linter.problems.none? { |e| e[:check] == :syntax }
|
107
90
|
end
|
108
91
|
|
109
|
-
if PuppetLint.configuration.codeclimate_report_file
|
110
|
-
PuppetLint::Report::CodeClimateReporter.write_report_file(all_problems, PuppetLint.configuration.codeclimate_report_file)
|
111
|
-
end
|
92
|
+
PuppetLint::Report::CodeClimateReporter.write_report_file(all_problems, PuppetLint.configuration.codeclimate_report_file) if PuppetLint.configuration.codeclimate_report_file
|
112
93
|
|
113
94
|
abort if linter.errors? || (
|
114
95
|
linter.warnings? && PuppetLint.configuration.fail_on_warnings
|
@@ -27,7 +27,7 @@ def run_cmd(message, *cmd)
|
|
27
27
|
[output.strip, status.success?]
|
28
28
|
end
|
29
29
|
|
30
|
-
def with_puppet_lint_head
|
30
|
+
def with_puppet_lint_head(&block)
|
31
31
|
print(' Updating Gemfile to use puppet-lint HEAD... ')
|
32
32
|
|
33
33
|
buffer = Parser::Source::Buffer.new('Gemfile')
|
@@ -49,7 +49,7 @@ def with_puppet_lint_head
|
|
49
49
|
|
50
50
|
puts 'Done'
|
51
51
|
|
52
|
-
Bundler.with_clean_env
|
52
|
+
Bundler.with_clean_env(&block)
|
53
53
|
|
54
54
|
run_cmd('Restoring Gemfile', 'git', 'checkout', '--', 'Gemfile')
|
55
55
|
end
|
@@ -58,9 +58,9 @@ task :release_test do
|
|
58
58
|
branch = if ENV['GITHUB_REF']
|
59
59
|
ENV['GITHUB_REF']
|
60
60
|
elsif ENV['APPVEYOR']
|
61
|
-
ENV
|
61
|
+
ENV.fetch('APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH', nil)
|
62
62
|
elsif ENV['TRAVIS']
|
63
|
-
ENV
|
63
|
+
ENV.fetch('TRAVIS_PULL_REQUEST_BRANCH', nil)
|
64
64
|
else
|
65
65
|
false
|
66
66
|
end
|
data/lib/puppet-lint/version.rb
CHANGED
data/lib/puppet-lint.rb
CHANGED
@@ -95,7 +95,7 @@ class PuppetLint
|
|
95
95
|
|
96
96
|
# Check if the input is an SE Linux policy package file (which also use
|
97
97
|
# the .pp extension), which all have the first 4 bytes 0xf97cff8f.
|
98
|
-
@code = '' if @code[0..3].
|
98
|
+
@code = '' if @code[0..3].unpack1('V') == 0xf97cff8f
|
99
99
|
end
|
100
100
|
|
101
101
|
# Internal: Retrieve the format string to be used when writing problems to
|
@@ -155,8 +155,10 @@ class PuppetLint
|
|
155
155
|
def print_context(message)
|
156
156
|
return if message[:check] == 'documentation'
|
157
157
|
return if message[:kind] == :fixed
|
158
|
+
|
158
159
|
line = message[:context]
|
159
160
|
return unless line
|
161
|
+
|
160
162
|
offset = line.index(%r{\S}) || 1
|
161
163
|
puts "\n #{line.strip}"
|
162
164
|
printf("%#{message[:column] + 2 - offset}s\n\n", '^')
|
@@ -188,7 +190,7 @@ class PuppetLint
|
|
188
190
|
print_github_annotation(message) if configuration.github_actions
|
189
191
|
end
|
190
192
|
end
|
191
|
-
|
193
|
+
warn 'Try running `puppet parser validate <file>`' if problems.any? { |p| p[:check] == :syntax }
|
192
194
|
json
|
193
195
|
end
|
194
196
|
|
@@ -251,7 +253,7 @@ class PuppetLint
|
|
251
253
|
def self.new_check(name, &block)
|
252
254
|
class_name = name.to_s.split('_').map(&:capitalize).join
|
253
255
|
klass = PuppetLint.const_set("Check#{class_name}", Class.new(PuppetLint::CheckPlugin))
|
254
|
-
klass.const_set(
|
256
|
+
klass.const_set(:NAME, name)
|
255
257
|
klass.class_exec(&block)
|
256
258
|
PuppetLint.configuration.add_check(name, klass)
|
257
259
|
PuppetLint::Data.ignore_overrides[name] ||= {}
|