Code comment in ShurlySettingsForm is inaccurate

Created on 2 February 2023, almost 2 years ago
Updated 7 February 2023, almost 2 years ago

Problem/Motivation

We need to deal with an empty value here. But then wie don't need to validate the url.

1) Comment has a typo.
2) Most importantly, comment doesn't make sense, we are actually checking that the URL is valid.

As UrlHelper::isValid($custom_base_url, $absolute = TRUE) will return false but then we use ! to make it true, so it passes the conditional and error message is invoked.

Steps to reproduce

Take a look at ShurlySettingsForm.php#L201

Proposed resolution

Remove comment in favor of a more self explanatory code, which won't require devs to parse the conditional in their head and also won't require a comment since it's self explanatory.

$not_a_valid_url = !empty($custom_base_url) && !UrlHelper::isValid($custom_base_url, $absolute = TRUE);
if ($not_a_valid_url) {
📌 Task
Status

Fixed

Version

1.0

Component

Code

Created by

🇨🇦Canada No Sssweat

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024