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
commitfed0a6e7ac361af9b963c1f62411b1a85478230c (patch)
tree5cde64a24845c761890fbcbe05e0d702f1ec8df7 /crates/shirabe/src/util/config_validator.rs
parente093b2be1c333e67c96aebb0a5291bea9ae3d6db (diff)
downloadphp-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.tar.gz
php-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.tar.zst
php-shirabe-fed0a6e7ac361af9b963c1f62411b1a85478230c.zip
refactor(preg): add preg_is_match for existence-only call sites
The capture groups were discarded at 162 of the preg_match call sites, which only tested the Option. They now call preg_is_match, which lets the regex engine skip capture tracking. 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.rs13
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/shirabe/src/util/config_validator.rs b/crates/shirabe/src/util/config_validator.rs
index e9282a9f..f8018fe5 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_match, preg_replace};
+use shirabe_php_shim::{PhpMixed, php_regex, preg_is_match, preg_replace};
use shirabe_spdx_licenses::SpdxLicenses;
#[derive(Debug)]
@@ -117,16 +117,13 @@ 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_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license).is_some()
- {
+ if preg_is_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?\+$}i"), license) {
warnings.push(format!(
"License \"{}\" is a deprecated SPDX license identifier, use \"{}-or-later\" instead",
license,
license.replace('+', "")
));
- } else if preg_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license)
- .is_some()
- {
+ } else if preg_is_match(php_regex!(r"{^[AL]?GPL-[123](\.[01])?$}i"), license) {
warnings.push(format!(
"License \"{}\" is a deprecated SPDX license identifier, use \"{}-only\" or \"{}-or-later\" instead",
license, license, license
@@ -147,7 +144,7 @@ impl ConfigValidator {
if let Some(PhpMixed::String(name)) = manifest.get("name")
&& !name.is_empty()
- && preg_match(php_regex!(r"{[A-Z]}"), name).is_some()
+ && preg_is_match(php_regex!(r"{[A-Z]}"), name)
{
let suggest_name = preg_replace(
php_regex!(r"{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}"),
@@ -224,7 +221,7 @@ impl ConfigValidator {
packages.extend(require_dev);
for (package, version) in &packages {
if let PhpMixed::String(version_str) = version
- && preg_match(php_regex!(r"{#}"), version_str).is_some()
+ && preg_is_match(php_regex!(r"{#}"), version_str)
{
warnings.push(format!(
"The package \"{}\" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.",