| 
									
										
										
										
											2024-08-12 10:30:59 +01:00
										 |  |  | # typed: true # rubocop:todo Sorbet/StrictSigil | 
					
						
							| 
									
										
										
										
											2019-04-19 15:38:03 +09:00
										 |  |  | # frozen_string_literal: true | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-20 10:22:39 -08:00
										 |  |  | require "rubocops/extend/formula_cop" | 
					
						
							| 
									
										
										
										
											2020-07-30 16:29:12 +01:00
										 |  |  | require "rubocops/shared/desc_helper" | 
					
						
							| 
									
										
										
										
											2017-03-02 20:26:29 +05:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-02 01:10:36 +05:30
										 |  |  | module RuboCop | 
					
						
							|  |  |  |   module Cop | 
					
						
							| 
									
										
										
										
											2018-04-25 07:48:21 +10:00
										 |  |  |     module FormulaAudit | 
					
						
							| 
									
										
										
										
											2020-11-05 17:17:03 -05:00
										 |  |  |       # This cop audits `desc` in formulae. | 
					
						
							|  |  |  |       # See the {DescHelper} module for details of the checks. | 
					
						
							| 
									
										
										
										
											2023-02-20 18:10:59 -08:00
										 |  |  |       class Desc < FormulaCop | 
					
						
							| 
									
										
										
										
											2020-07-30 16:29:12 +01:00
										 |  |  |         include DescHelper | 
					
						
							| 
									
										
										
										
											2021-01-12 18:12:56 +11:00
										 |  |  |         extend AutoCorrector | 
					
						
							| 
									
										
										
										
											2017-06-08 15:13:06 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-07 15:18:29 -04:00
										 |  |  |         sig { override.params(formula_nodes: FormulaNodes).void } | 
					
						
							|  |  |  |         def audit_formula(formula_nodes) | 
					
						
							|  |  |  |           body_node = formula_nodes.body_node | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-12 18:12:56 +11:00
										 |  |  |           @name = @formula_name | 
					
						
							| 
									
										
										
										
											2017-06-19 00:36:18 -04:00
										 |  |  |           desc_call = find_node_method_by_name(body_node, :desc) | 
					
						
							| 
									
										
										
										
											2024-07-07 15:18:29 -04:00
										 |  |  |           offending_node(formula_nodes.class_node) if body_node.nil? | 
					
						
							| 
									
										
										
										
											2021-01-12 18:12:56 +11:00
										 |  |  |           audit_desc(:formula, @name, desc_call) | 
					
						
							| 
									
										
										
										
											2017-03-12 02:55:21 +08:00
										 |  |  |         end | 
					
						
							| 
									
										
										
										
											2017-03-02 01:10:36 +05:30
										 |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end |