From e093b2be1c333e67c96aebb0a5291bea9ae3d6db Mon Sep 17 00:00:00 2001 From: nsfisis Date: Tue, 18 Aug 2026 01:57:02 +0900 Subject: refactor(preg): drop the offset argument from preg_match Every call site but one passed offset 0. The remaining one, the UTF-8 chunking loop in Application, slices the subject instead: its pattern has no anchor or lookaround, so matching a suffix is equivalent to starting the search at that offset. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/util/config_validator.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/shirabe/src/util/config_validator.rs') diff --git a/crates/shirabe/src/util/config_validator.rs b/crates/shirabe/src/util/config_validator.rs index 52560caa..e9282a9f 100644 --- a/crates/shirabe/src/util/config_validator.rs +++ b/crates/shirabe/src/util/config_validator.rs @@ -10,7 +10,7 @@ use crate::package::loader::ValidatingArrayLoader; use indexmap::IndexMap; use serde::de::Error as _; use shirabe_php_shim::Catch as _; -use shirabe_php_shim::{PhpMixed, php_regex, preg_match2, preg_replace}; +use shirabe_php_shim::{PhpMixed, php_regex, preg_match, preg_replace}; use shirabe_spdx_licenses::SpdxLicenses; #[derive(Debug)] @@ -117,15 +117,14 @@ impl ConfigValidator { for license in &licenses { let spdx_license = license_validator.get_license_by_identifier(license); if spdx_license.is_some_and(|l| l.is_deprecated_license_id) { - if preg_match2(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license, 0) - .is_some() + if preg_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license).is_some() { warnings.push(format!( "License \"{}\" is a deprecated SPDX license identifier, use \"{}-or-later\" instead", license, license.replace('+', "") )); - } else if preg_match2(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license, 0) + } else if preg_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license) .is_some() { warnings.push(format!( @@ -148,7 +147,7 @@ impl ConfigValidator { if let Some(PhpMixed::String(name)) = manifest.get("name") && !name.is_empty() - && preg_match2(php_regex!(r"{[A-Z]}"), name, 0).is_some() + && preg_match(php_regex!(r"{[A-Z]}"), name).is_some() { let suggest_name = preg_replace( php_regex!(r"{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}"), @@ -225,7 +224,7 @@ impl ConfigValidator { packages.extend(require_dev); for (package, version) in &packages { if let PhpMixed::String(version_str) = version - && preg_match2(php_regex!(r"{#}"), version_str, 0).is_some() + && preg_match(php_regex!(r"{#}"), version_str).is_some() { warnings.push(format!( "The package \"{}\" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.", -- cgit v1.3.1-4-g156e