Skip to content

Commit aa22009

Browse files
committed
update smell name
1 parent 22d614d commit aa22009

13 files changed

Lines changed: 258 additions & 124 deletions

File tree

‎Cargo.lock‎

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎plceye/src/analysis/l5x_analysis.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! L5X project-wide analysis.
22
//!
33
//! This module provides the core analysis engine that walks L5X project
4-
//! structures and builds cross-reference indices for smell detection.
4+
//! structures and builds cross-reference indices for rule detection.
55
66
use std::collections::{HashMap, HashSet};
77

‎plceye/src/config.rs‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Configuration for the smell detector.
1+
//! Configuration for the rule detector.
22
//!
33
//! Configuration can be loaded from a `plceye.toml` file.
44
@@ -8,10 +8,10 @@ use std::path::Path;
88
use crate::{Error, Result};
99
use crate::error::ConfigErrorKind;
1010

11-
/// Main configuration for the smell detector.
11+
/// Main configuration for the rule detector.
1212
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
1313
#[serde(default)]
14-
pub struct SmellConfig {
14+
pub struct RuleConfig {
1515
/// Global settings
1616
pub general: GeneralConfig,
1717

@@ -25,7 +25,7 @@ pub struct SmellConfig {
2525
pub empty_routines: EmptyRoutinesConfig,
2626
}
2727

28-
impl SmellConfig {
28+
impl RuleConfig {
2929
/// Load configuration from a TOML file.
3030
pub fn from_file(path: &Path) -> Result<Self> {
3131
let content = std::fs::read_to_string(path).map_err(|e| Error::FileRead {
@@ -44,7 +44,7 @@ impl SmellConfig {
4444

4545
/// Generate a default configuration file as a string.
4646
pub fn default_toml() -> String {
47-
r#"# plceye.toml - PLC Code Smell Detector Configuration
47+
r#"# plceye.toml - PLC Code Rule Detector Configuration
4848
4949
[general]
5050
# Minimum severity to report: "info", "warning", "error"
@@ -173,7 +173,7 @@ mod tests {
173173

174174
#[test]
175175
fn test_default_config() {
176-
let config = SmellConfig::default();
176+
let config = RuleConfig::default();
177177
assert!(config.unused_tags.enabled);
178178
assert_eq!(config.general.min_severity, "info");
179179
}
@@ -189,16 +189,16 @@ enabled = true
189189
ignore_patterns = ["Test_*", "Debug_*"]
190190
ignore_scopes = ["Program:Debug"]
191191
"#;
192-
let config = SmellConfig::parse(toml).unwrap();
192+
let config = RuleConfig::parse(toml).unwrap();
193193
assert_eq!(config.general.min_severity, "warning");
194194
assert!(config.unused_tags.enabled);
195195
assert_eq!(config.unused_tags.ignore_patterns.len(), 2);
196196
}
197197

198198
#[test]
199199
fn test_default_toml_parses() {
200-
let toml = SmellConfig::default_toml();
201-
let config = SmellConfig::parse(&toml).unwrap();
200+
let toml = RuleConfig::default_toml();
201+
let config = RuleConfig::parse(&toml).unwrap();
202202
assert!(config.unused_tags.enabled);
203203
}
204204
}

‎plceye/src/detector.rs‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
//! Main smell detector that coordinates all individual detectors.
1+
//! Main rule detector that coordinates all individual detectors.
22
33
use std::path::Path;
44

55
use l5x::Controller;
66

77
use crate::analysis::{analyze_controller, analyze_plcopen_project, ParseStats, PlcopenStats};
8-
use crate::config::SmellConfig;
8+
use crate::config::RuleConfig;
99
use crate::loader::LoadedProject;
1010
use crate::report::{Report, Severity};
11-
use crate::smells::{
11+
use crate::rules::{
1212
EmptyRoutinesDetector, UndefinedTagsDetector, UnusedTagsDetector,
1313
PlcopenUnusedVarsDetector, PlcopenUndefinedVarsDetector, PlcopenEmptyPousDetector,
1414
};
1515
use 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
}

‎plceye/src/error.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
//! Error types for the smell detector.
1+
//! Error types for the rule detector.
22
33
use thiserror::Error;
44

5-
/// Result type alias for smell operations.
5+
/// Result type alias for rule operations.
66
pub type Result<T> = std::result::Result<T, Error>;
77

8-
/// Error types for the smell detector.
8+
/// Error types for the rule detector.
99
#[derive(Debug, Error)]
1010
pub enum Error {
1111
/// Failed to read file

‎plceye/src/lib.rs‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
//! plceye - PLC Code Smell Detector
1+
//! plceye - PLC Code Rule Detector
22
//!
3-
//! Open source static analyzer for PLC files that detects code smells
3+
//! Open source static analyzer for PLC files that detects code rules
44
//! and potential issues in PLC programs.
55
//!
66
//! ## Supported Formats
77
//!
88
//! - **L5X** - Rockwell Automation Studio 5000
99
//! - **PLCopen XML** - IEC 61131-3 standard exchange format
1010
//!
11-
//! ## Supported Smells
11+
//! ## Supported Rules
1212
//!
1313
//! - **unused_tags** - Tags defined but never used
1414
//! - **undefined_tags** - Tags referenced but not defined
@@ -31,19 +31,20 @@ mod detector;
3131
mod error;
3232
mod loader;
3333
mod report;
34-
mod smells;
34+
mod rules;
3535

3636
// Core types
37-
pub use config::{SmellConfig, GeneralConfig, UnusedTagsConfig, UndefinedTagsConfig, EmptyRoutinesConfig};
38-
pub use detector::SmellDetector;
37+
pub use config::{RuleConfig, GeneralConfig, UnusedTagsConfig, UndefinedTagsConfig, EmptyRoutinesConfig};
38+
pub use detector::RuleDetector;
3939
pub use error::{Error, Result, L5xParseErrorKind, ConfigErrorKind};
4040
pub use loader::{LoadedProject, FileFormat};
41-
pub use report::{Report, Smell, Severity, SmellKind};
41+
pub use report::{Report, Rule, Severity, RuleKind};
4242

4343
// Analysis types (for extensions)
4444
pub use analysis::{ProjectAnalysis, ParseStats, analyze_controller};
4545
pub use analysis::{PlcopenAnalysis, PlcopenStats, analyze_plcopen_project};
4646

4747
// Re-export parser crates for extensions
48+
pub use iecst;
4849
pub use l5x;
4950
pub use plcopen;

‎plceye/src/main.rs‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
//! plceye - PLC Code Smell Detector CLI
1+
//! plceye - PLC Code Rule Detector CLI
22
33
use std::path::{Path, PathBuf};
44
use std::process::ExitCode;
55

66
use clap::{Parser, Subcommand};
7-
use plceye::{SmellConfig, SmellDetector, Report, ParseStats};
7+
use plceye::{RuleConfig, RuleDetector, Report, ParseStats};
88

99
#[derive(Parser)]
1010
#[command(name = "plceye")]
11-
#[command(version, about = "PLC code smell detector for L5X files", long_about = None)]
11+
#[command(version, about = "PLC code rule detector for L5X files", long_about = None)]
1212
struct Cli {
1313
#[command(subcommand)]
1414
command: Option<Commands>,
@@ -25,7 +25,7 @@ struct Cli {
2525
#[arg(short, long, value_name = "LEVEL", default_value = "info")]
2626
severity: String,
2727

28-
/// Show file statistics only (no smell detection)
28+
/// Show file statistics only (no rule detection)
2929
#[arg(long)]
3030
stats: bool,
3131
}
@@ -59,29 +59,29 @@ fn main() -> ExitCode {
5959

6060
// Load or create configuration
6161
let mut config = if let Some(ref path) = cli.config {
62-
match SmellConfig::from_file(path) {
62+
match RuleConfig::from_file(path) {
6363
Ok(c) => c,
6464
Err(e) => {
6565
eprintln!("Error loading config: {}", e);
6666
return ExitCode::from(1);
6767
}
6868
}
6969
} else if Path::new("plceye.toml").exists() {
70-
match SmellConfig::from_file(Path::new("plceye.toml")) {
70+
match RuleConfig::from_file(Path::new("plceye.toml")) {
7171
Ok(c) => c,
7272
Err(e) => {
7373
eprintln!("Warning: Failed to load plceye.toml: {}", e);
74-
SmellConfig::default()
74+
RuleConfig::default()
7575
}
7676
}
7777
} else {
78-
SmellConfig::default()
78+
RuleConfig::default()
7979
};
8080

8181
// Apply severity from CLI
8282
config.general.min_severity = cli.severity.clone();
8383

84-
let detector = SmellDetector::with_config(config);
84+
let detector = RuleDetector::with_config(config);
8585
let min_severity = detector.min_severity();
8686

8787
// Collect all results
@@ -111,8 +111,8 @@ fn main() -> ExitCode {
111111
let filtered = report.filter_by_severity(min_severity);
112112
if !filtered.is_empty() {
113113
println!("\n=== {} ===", file);
114-
for smell in filtered {
115-
println!("{}", smell);
114+
for rule in filtered {
115+
println!("{}", rule);
116116
}
117117
}
118118
}
@@ -140,7 +140,7 @@ fn init_config() -> ExitCode {
140140
return ExitCode::from(1);
141141
}
142142

143-
let content = SmellConfig::default_toml();
143+
let content = RuleConfig::default_toml();
144144
match std::fs::write(path, content) {
145145
Ok(_) => {
146146
println!("Created plceye.toml with default configuration");
@@ -154,7 +154,7 @@ fn init_config() -> ExitCode {
154154
}
155155

156156
fn show_stats(files: &[PathBuf]) -> ExitCode {
157-
let detector = SmellDetector::new();
157+
let detector = RuleDetector::new();
158158
let mut has_errors = false;
159159

160160
for file in files {

0 commit comments

Comments
 (0)