1- //! Main smell detector that coordinates all individual detectors.
1+ //! Main rule detector that coordinates all individual detectors.
22
33use std:: path:: Path ;
44
55use l5x:: Controller ;
66
77use crate :: analysis:: { analyze_controller, analyze_plcopen_project, ParseStats , PlcopenStats } ;
8- use crate :: config:: SmellConfig ;
8+ use crate :: config:: RuleConfig ;
99use crate :: loader:: LoadedProject ;
1010use crate :: report:: { Report , Severity } ;
11- use crate :: smells :: {
11+ use crate :: rules :: {
1212 EmptyRoutinesDetector , UndefinedTagsDetector , UnusedTagsDetector ,
1313 PlcopenUnusedVarsDetector , PlcopenUndefinedVarsDetector , PlcopenEmptyPousDetector ,
1414} ;
1515use crate :: Result ;
1616
17- /// Main smell detector that runs all enabled detectors.
18- pub struct SmellDetector {
19- config : SmellConfig ,
17+ /// Main rule detector that runs all enabled detectors.
18+ pub struct RuleDetector {
19+ config : RuleConfig ,
2020}
2121
22- impl SmellDetector {
23- /// Create a new smell detector with default configuration.
22+ impl RuleDetector {
23+ /// Create a new rule detector with default configuration.
2424 pub fn new ( ) -> Self {
2525 Self {
26- config : SmellConfig :: default ( ) ,
26+ config : RuleConfig :: default ( ) ,
2727 }
2828 }
2929
30- /// Create a new smell detector with the given configuration.
31- pub fn with_config ( config : SmellConfig ) -> Self {
30+ /// Create a new rule detector with the given configuration.
31+ pub fn with_config ( config : RuleConfig ) -> Self {
3232 Self { config }
3333 }
3434
3535 /// Load configuration from a file.
3636 pub fn from_config_file ( path : & Path ) -> Result < Self > {
37- let config = SmellConfig :: from_file ( path) ?;
37+ let config = RuleConfig :: from_file ( path) ?;
3838 Ok ( Self { config } )
3939 }
4040
4141 /// Get the current configuration.
42- pub fn config ( & self ) -> & SmellConfig {
42+ pub fn config ( & self ) -> & RuleConfig {
4343 & self . config
4444 }
4545
@@ -112,7 +112,7 @@ impl SmellDetector {
112112 Ok ( report)
113113 }
114114
115- /// Get statistics for a file without running smell detection.
115+ /// Get statistics for a file without running rule detection.
116116 pub fn get_stats_file ( & self , path : & Path ) -> Result < ParseStats > {
117117 let project = LoadedProject :: from_file ( path) ?;
118118 self . get_stats ( & project)
@@ -140,7 +140,7 @@ impl SmellDetector {
140140 }
141141}
142142
143- impl Default for SmellDetector {
143+ impl Default for RuleDetector {
144144 fn default ( ) -> Self {
145145 Self :: new ( )
146146 }
@@ -152,15 +152,15 @@ mod tests {
152152
153153 #[ test]
154154 fn test_detector_default ( ) {
155- let detector = SmellDetector :: new ( ) ;
155+ let detector = RuleDetector :: new ( ) ;
156156 assert ! ( detector. config( ) . unused_tags. enabled) ;
157157 }
158158
159159 #[ test]
160160 fn test_detector_with_config ( ) {
161- let mut config = SmellConfig :: default ( ) ;
161+ let mut config = RuleConfig :: default ( ) ;
162162 config. unused_tags . enabled = false ;
163- let detector = SmellDetector :: with_config ( config) ;
163+ let detector = RuleDetector :: with_config ( config) ;
164164 assert ! ( !detector. config( ) . unused_tags. enabled) ;
165165 }
166166
@@ -189,11 +189,11 @@ mod tests {
189189 </RSLogix5000Content>"# ;
190190
191191 let project = LoadedProject :: from_str ( xml, None ) . expect ( "Should parse" ) ;
192- let detector = SmellDetector :: new ( ) ;
192+ let detector = RuleDetector :: new ( ) ;
193193 let report = detector. analyze ( & project) . expect ( "Should analyze" ) ;
194194
195195 // Should detect unused tag
196- assert ! ( !report. smells . is_empty( ) ) ;
196+ assert ! ( !report. rules . is_empty( ) ) ;
197197 }
198198
199199 #[ test]
@@ -210,10 +210,10 @@ mod tests {
210210 </project>"# ;
211211
212212 let project = LoadedProject :: from_str ( xml, None ) . expect ( "Should parse" ) ;
213- let detector = SmellDetector :: new ( ) ;
213+ let detector = RuleDetector :: new ( ) ;
214214 let report = detector. analyze ( & project) . expect ( "Should analyze" ) ;
215215
216216 // Should detect empty POU
217- assert ! ( report. smells . iter( ) . any( |s| s. identifier == "Main" ) ) ;
217+ assert ! ( report. rules . iter( ) . any( |s| s. identifier == "Main" ) ) ;
218218 }
219219}
0 commit comments