| 
									
										
										
										
											2024-08-12 10:30:59 +01:00
										 |  |  | # typed: true # rubocop:todo Sorbet/StrictSigil | 
					
						
							| 
									
										
										
										
											2022-11-19 21:46:58 -08:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module RuboCop | 
					
						
							|  |  |  |   module Cop | 
					
						
							|  |  |  |     module Homebrew | 
					
						
							|  |  |  |       # This cop ensures that platform specific code ends up in `extend/os`. | 
					
						
							|  |  |  |       class MoveToExtendOS < Base | 
					
						
							| 
									
										
										
										
											2022-11-21 22:14:04 -08:00
										 |  |  |         MSG = "Move `OS.linux?` and `OS.mac?` calls to `extend/os`." | 
					
						
							| 
									
										
										
										
											2022-11-19 21:46:58 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         def_node_matcher :os_check?, <<~PATTERN | 
					
						
							|  |  |  |           (send (const nil? :OS) {:mac? | :linux?}) | 
					
						
							|  |  |  |         PATTERN | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def on_send(node) | 
					
						
							|  |  |  |           return unless os_check?(node) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           add_offense(node) | 
					
						
							|  |  |  |         end | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |