| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-26 19:41:14 +01:00
										 |  |  | require "rubocops/caveats" | 
					
						
							| 
									
										
										
										
											2017-05-22 13:09:49 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | describe RuboCop::Cop::FormulaAudit::Caveats do | 
					
						
							|  |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-12-23 18:02:25 -08:00
										 |  |  |   context "when auditing `caveats`" do | 
					
						
							|  |  |  |     it "reports an offense if `setuid` is mentioned" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-11-28 20:51:55 +01:00
										 |  |  |           homepage "https://brew.sh/foo" | 
					
						
							|  |  |  |           url "https://brew.sh/foo-1.0.tgz" | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |            def caveats | 
					
						
							|  |  |  |             "setuid" | 
					
						
							| 
									
										
										
										
											2023-04-07 17:16:48 +01:00
										 |  |  |             ^^^^^^^^ FormulaAudit/Caveats: Don't recommend setuid in the caveats, suggest sudo instead. | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |           end | 
					
						
							| 
									
										
										
										
											2017-05-22 13:09:49 +05:30
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-22 13:09:49 +05:30
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2023-01-16 01:24:23 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it "reports an offense if an escape character is present" do | 
					
						
							|  |  |  |       expect_offense(<<~RUBY) | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           homepage "https://brew.sh/foo" | 
					
						
							|  |  |  |           url "https://brew.sh/foo-1.0.tgz" | 
					
						
							|  |  |  |            def caveats | 
					
						
							|  |  |  |             "\\x1B" | 
					
						
							| 
									
										
										
										
											2023-04-07 17:16:48 +01:00
										 |  |  |             ^^^^^^ FormulaAudit/Caveats: Don't use ANSI escape codes in the caveats. | 
					
						
							| 
									
										
										
										
											2023-01-16 01:24:23 -05:00
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect_offense(<<~RUBY) | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							|  |  |  |           homepage "https://brew.sh/foo" | 
					
						
							|  |  |  |           url "https://brew.sh/foo-1.0.tgz" | 
					
						
							|  |  |  |            def caveats | 
					
						
							|  |  |  |             "\\u001b" | 
					
						
							| 
									
										
										
										
											2023-04-07 17:16:48 +01:00
										 |  |  |             ^^^^^^^^ FormulaAudit/Caveats: Don't use ANSI escape codes in the caveats. | 
					
						
							| 
									
										
										
										
											2023-01-16 01:24:23 -05:00
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-05-22 13:09:49 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | end |