aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/config_validator.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
committernsfisis <nsfisis@gmail.com>2026-08-18 01:57:02 +0900
commite093b2be1c333e67c96aebb0a5291bea9ae3d6db (patch)
tree0743fad689f419959c3a898605e21485087884fa /crates/shirabe/src/util/config_validator.rs
parent050c56ef263d90d862ef565bc1762909110e02eb (diff)
downloadphp-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.gz
php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.zst
php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.zip
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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/util/config_validator.rs')
-rw-r--r--crates/shirabe/src/util/config_validator.rs11
1 files changed, 5 insertions, 6 deletions
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.",