| 
									
										
										
										
											2018-09-02 23:30:07 +02:00
										 |  |  | require "rubocops/text_cop" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  | describe RuboCop::Cop::FormulaAudit::Text do | 
					
						
							|  |  |  |   subject(:cop) { described_class.new } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   context "When auditing formula text" do | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  |     it "with both openssl and libressl optional dependencies" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           depends_on "openssl" | 
					
						
							|  |  |  |           depends_on "libressl" => :optional | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Formulae should not depend on both OpenSSL and LibreSSL (even optionally). | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "with both openssl and libressl dependencies" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           depends_on "openssl" | 
					
						
							|  |  |  |           depends_on "libressl" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^^^^^^^^^^^^^ Formulae should not depend on both OpenSSL and LibreSSL (even optionally). | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-08-06 14:48:39 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     it "When xcodebuild is called without SYMROOT" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             xcodebuild "-project", "meow.xcodeproject" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ xcodebuild should be passed an explicit \"SYMROOT\"
 | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "When xcodebuild is called without any args" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             xcodebuild | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |             ^^^^^^^^^^ xcodebuild should be passed an explicit \"SYMROOT\"
 | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "When go get is executed" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             system "go", "get", "bar" | 
					
						
							| 
									
										
										
										
											2017-10-31 01:01:42 +00:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use `go get`. Please ask upstream to implement Go vendoring | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "When xcodebuild is executed" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             system "xcodebuild", "foo", "bar" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use \"xcodebuild *args\" instead of \"system 'xcodebuild', *args\"
 | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "When scons is executed" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             system "scons", "foo", "bar" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use \"scons *args\" instead of \"system 'scons', *args\"
 | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |     it "When plist_options are not defined when using a formula-defined plist", :ruby23 do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             system "xcodebuild", "foo", "bar" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ use \"xcodebuild *args\" instead of \"system 'xcodebuild', *args\"
 | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |           def plist | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^ Please set plist_options when using a formula-defined plist. | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |             <<~XML | 
					
						
							|  |  |  |               <?xml version="1.0" encoding="UTF-8"?> | 
					
						
							|  |  |  |               <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | 
					
						
							|  |  |  |               <plist version="1.0"> | 
					
						
							|  |  |  |               <dict> | 
					
						
							|  |  |  |                 <key>Label</key>
 | 
					
						
							|  |  |  |                 <string>org.nrpe.agent</string>
 | 
					
						
							|  |  |  |               </dict>
 | 
					
						
							|  |  |  |               </plist>
 | 
					
						
							|  |  |  |             XML | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-15 02:28:32 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "When language/go is require'd" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         require "language/go" | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |         ^^^^^^^^^^^^^^^^^^^^^ require "language/go" is unnecessary unless using `go_resource`s | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             system "go", "get", "bar" | 
					
						
							| 
									
										
										
										
											2017-10-31 01:01:42 +00:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use `go get`. Please ask upstream to implement Go vendoring | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "When formula uses virtualenv and also `setuptools` resource" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           resource "setuptools" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |           ^^^^^^^^^^^^^^^^^^^^^ Formulae using virtualenvs do not need a `setuptools` resource. | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |             url "https://foo.com/foo.tar.gz" | 
					
						
							|  |  |  |             sha256 "db0904a28253cfe53e7dedc765c71596f3c53bb8a866ae50123320ec1a7b73fd" | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             virtualenv_create(libexec) | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it "When Formula.factory(name) is used" do | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       expect_offense(<<~RUBY) | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             Formula.factory(name) | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^ \"Formula.factory(name)\" is deprecated in favor of \"Formula[name]\"
 | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-10-21 03:12:50 +02:00
										 |  |  |       RUBY | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-06-08 00:07:07 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it "When dep ensure is used without `-vendor-only`" do | 
					
						
							|  |  |  |       expect_offense(<<~RUBY) | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2018-06-08 00:07:07 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             system "dep", "ensure" | 
					
						
							|  |  |  |             ^^^^^^^^^^^^^^^^^^^^^^ use \"dep\", \"ensure\", \"-vendor-only\"
 | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2018-06-08 10:15:32 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it "When cargo build is executed" do | 
					
						
							|  |  |  |       expect_offense(<<~RUBY) | 
					
						
							|  |  |  |         class Foo < Formula | 
					
						
							| 
									
										
										
										
											2018-08-06 20:41:21 +02:00
										 |  |  |           url "https://example.com/foo-1.0.tgz" | 
					
						
							|  |  |  |           homepage "https://example.com" | 
					
						
							| 
									
										
										
										
											2018-06-08 10:15:32 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |           def install | 
					
						
							|  |  |  |             system "cargo", "build" | 
					
						
							| 
									
										
										
										
											2018-08-29 23:03:02 +10:00
										 |  |  |             ^^^^^^^^^^^^^^^^^^^^^^^ use \"cargo\", \"install\", \"--root\", prefix, \"--path\", \".\"
 | 
					
						
							| 
									
										
										
										
											2018-06-08 10:15:32 +10:00
										 |  |  |           end | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       RUBY | 
					
						
							|  |  |  |     end | 
					
						
							| 
									
										
										
										
											2017-05-24 00:08:31 +05:30
										 |  |  |   end | 
					
						
							|  |  |  | end |