Skip to content

feat/CUS-11476-Added class to store the count matching regex#360

Merged
akhil-testsigma merged 1 commit into
devfrom
feat/CUS-11476-Added-class-to-store-the-count-matching-regex
Mar 23, 2026
Merged

feat/CUS-11476-Added class to store the count matching regex#360
akhil-testsigma merged 1 commit into
devfrom
feat/CUS-11476-Added-class-to-store-the-count-matching-regex

Conversation

@akhil-testsigma
Copy link
Copy Markdown
Contributor

@akhil-testsigma akhil-testsigma commented Mar 23, 2026

Publish this addon as PUBLIC

Addon Name: Validate data with regex pattern
Jarvis Link: https://jarvis.testsigma.com/ui/tenants/2817/addons
Jira : https://testsigma.atlassian.net/browse/CUS-11476
Added class to store the count matching regex

Summary by CodeRabbit

Release Notes

  • New Features

    • Added regex pattern matching and validation actions across Android, iOS, Windows, Web, and Mobile Web platforms
    • New actions to count regex matches, verify patterns match text, and store matched values to variables with flexible occurrence selection
  • Improvements

    • Enhanced clarity of user-facing messages for regex match operations

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

The pull request updates the Maven artifact version to 1.0.7 and introduces new regex action classes for extracting and counting pattern matches across multiple platforms (Android, iOS, Desktop, Web, Mobile Web). Additionally, existing occurrence-based regex actions are updated to remove platform-specific language from their messaging output.

Changes

Cohort / File(s) Summary
Maven Configuration
validate_data_with_regex_pattern/pom.xml
Version bump from 1.0.6 to 1.0.7.
Regex Count Actions
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexCountValue.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexCountValue.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexCountValue.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexCountValue.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexCountValue.java
New actions added across all platforms to count regex pattern matches in input strings and store the count in runtime variables. Implementations follow consistent pattern: compile regex, iterate through matches, store count as string.
Regex Pattern Matching
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java
New actions for Desktop and Web platforms that verify if text matches a given regex pattern using matcher.matches(). Web version includes expanded logging around regex compilation and matcher creation.
Regex Variable Storage
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java
New Desktop action to extract first regex match and store in runtime variable. Test class added for Web platform with hardcoded regex matching logic.
Regex Occurrence Extraction
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java, validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java
New Desktop occurrence action added; existing Android, iOS, Mobile Web, and Web occurrence actions updated to remove "second" references from log/message outputs and add console print statement for matched string.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • Ganesh-Testsigma
  • vigneshtestsigma

Poem

🐰 Counting matches with hopping delight,
Patterns extracted left, center, and right,
From Android to Web, each platform aligned,
Regex actions so clever and refined!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is related to the main changes in the PR but is incomplete and misleading. While several new classes to store matching regex counts were added across multiple platforms (Android, iOS, Desktop, Web, Mobile Web), the title only mentions 'store the count matching regex' without indicating the broader scope. Additionally, other significant changes include new regex pattern matching verification actions and updates to existing regex extraction functionality, which are not captured in the title. Consider revising the title to reflect the scope more accurately, such as: 'feat/CUS-11476: Add regex pattern matching and count storage across platforms' to better represent all added functionality.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/CUS-11476-Added-class-to-store-the-count-matching-regex

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🧹 Nitpick comments (14)
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java (2)

6-6: Remove unused import WebAction.

The class extends IOSAction, making the WebAction import unnecessary.

♻️ Proposed fix
 import com.testsigma.sdk.IOSAction;
 import com.testsigma.sdk.Result;
-import com.testsigma.sdk.WebAction;
 import com.testsigma.sdk.annotation.Action;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java`
at line 6, Remove the unused import com.testsigma.sdk.WebAction from the top of
the file; the class StoreMatchingRegexValueInAVariableOccurrence already extends
IOSAction so WebAction is not referenced—delete the import line and run a quick
compile or organize/imports to ensure no other unused imports remain.

76-76: Replace System.out.println with logger for consistency.

Same issue as other platform variants—use logger.info() instead.

♻️ Proposed fix
-            System.out.println("Matched string : " + matchedString);
+            logger.info("Matched string : " + matchedString);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java`
at line 76, Replace the System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with logger.info(...) for consistency with other variants;
use the existing logger instance (or add a private static final Logger logger if
missing) and format the message the same way ("Matched string : " +
matchedString) so logging is consistent across platforms.
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java (3)

63-68: Remove commented-out code.

Commented-out main method should be deleted to keep the codebase clean.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java`
around lines 63 - 68, Remove the commented-out main method block inside the
RegExPatternMatch class (the multi-line comment that contains "public static
void main" and the MyFirstWebAction setup lines) to clean up dead code; locate
the commented snippet in RegExPatternMatch.java and delete the entire commented
section including its opening /* and closing */ so no leftover commented test
code remains.

33-34: Remove duplicate logging.

Test data and regex pattern are logged at lines 33-34, then again at lines 40-41.

Also applies to: 40-41

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java`
around lines 33 - 34, The code currently logs testData and regExPattern twice in
RegExPatternMatch (logger.info("Test Data::" + testData.getValue()) and
logger.info("RegEx Pattern::" + regExPattern.getValue()) appear at both sets of
lines); remove the duplicate pair so each value is logged only once (keep one
pair of logger.info calls referencing testData.getValue() and
regExPattern.getValue(), and delete the other), ensuring the logger variable and
surrounding method behavior (in RegExPatternMatch) remain unchanged.

36-54: Simplify result handling—result variable is unused.

Since both branches return immediately, the result variable assignment on lines 36, 51, and 56 is redundant.

♻️ Proposed simplification
-        com.testsigma.sdk.Result result = com.testsigma.sdk.Result.SUCCESS;
-
         try {
             logger.info("Compiling the regex pattern and matching with the test data");
-            logger.info("Pattern::" + regExPattern.getValue().toString());
-            logger.info("Test Data::" + testData.getValue().toString());
 
             Pattern pattern = Pattern.compile(regExPattern.getValue().toString());
             logger.info("Pattern compiled successfully");
             Matcher matcher = pattern.matcher(testData.getValue().toString());
             logger.info("Matcher created successfully");
             if (matcher.matches()) {
                 setSuccessMessage("The input string matches the pattern.");
                 return Result.SUCCESS;
             } else {
-                result = com.testsigma.sdk.Result.FAILED;
                 setErrorMessage("The input string does not match the pattern.");
-                return result;
+                return Result.FAILED;
             }
         } catch (Exception error) {
-            result = com.testsigma.sdk.Result.FAILED;
             logger.info(" Exception occurred while executing the action::" + ExceptionUtils.getStackTrace(error));
             setErrorMessage("Exception occurred while executing the action::" + error.getMessage());
-            return result;
+            return Result.FAILED;
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java`
around lines 36 - 54, The local variable result in RegExPatternMatch is unused
because both branches return immediately; remove the declaration
"com.testsigma.sdk.Result result = com.testsigma.sdk.Result.SUCCESS;" and any
assignments to result (e.g., where it’s set to com.testsigma.sdk.Result.FAILED)
and instead directly return Result.FAILED in the failing branch (leave the
success branch returning Result.SUCCESS). Update the code around
Pattern.compile, Matcher matcher = pattern.matcher(...), and the if
(matcher.matches()) block accordingly to eliminate the redundant variable.
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java (1)

38-38: Use camelCase for local variables.

Regex should be regex to follow Java naming conventions.

♻️ Proposed fix
-        String Regex = regex.getValue().toString();
+        String regexValue = regex.getValue().toString();

Update subsequent usages (lines 42, 46) accordingly.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java`
at line 38, In StoreMatchingRegexValueInAVariable, rename the local variable
"Regex" to follow Java camelCase (e.g., "regex") where it's assigned from
regex.getValue().toString(), and update all subsequent usages in this
class/method (references to "Regex" later in the method) to the new name to keep
naming consistent and compile correctly.
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java (2)

6-6: Remove unused import WebAction.

The class extends AndroidAction, making the WebAction import unnecessary.

♻️ Proposed fix
 import com.testsigma.sdk.ApplicationType;
 import com.testsigma.sdk.Result;
-import com.testsigma.sdk.WebAction;
 import com.testsigma.sdk.annotation.Action;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java`
at line 6, Remove the unused import "com.testsigma.sdk.WebAction" from the top
of the file; the class StoreMatchingRegexValueInAVariableOccurrence already
extends AndroidAction so the WebAction import is unnecessary—delete the import
line to clean up unused dependencies.

76-76: Replace System.out.println with logger for consistency.

Same issue as other platform variants—use logger.info() instead.

♻️ Proposed fix
-            System.out.println("Matched string : " + matchedString);
+            logger.info("Matched string : " + matchedString);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java`
at line 76, Replace the direct stdout call with the class logger: in
StoreMatchingRegexValueInAVariableOccurrence where System.out.println("Matched
string : " + matchedString) is used, change it to use the class logger
(logger.info) and log the matchedString with the same message format; ensure you
reference the existing logger instance in that class and remove the
System.out.println call so logging is consistent across platform variants.
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java (2)

75-75: Replace System.out.println with logger for consistency.

The codebase uses logger.info() elsewhere for output. Using System.out.println bypasses the logging framework, making it harder to control log levels and capture output in test reports.

♻️ Proposed fix
-            System.out.println("Matched string : " + matchedString);
+            logger.info("Matched string : " + matchedString);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java`
at line 75, Replace the direct System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with the project's logger API—use logger.info with the same
message format so logs go through the logging framework and respect log levels;
locate the print in the method where matchedString is produced and swap it to
logger.info("Matched string : " + matchedString) (or the equivalent string
formatting used elsewhere) to keep output consistent.

46-47: Consider validating occurrenceValue for edge cases.

Integer.parseInt will throw NumberFormatException for non-integer inputs, which is caught by the generic Exception handler. However, there's no validation for invalid occurrence values (e.g., 0 or negative numbers), which would silently result in no match being found.

💡 Proposed validation
         int occurrenceValue = Integer.parseInt(occurrence.getValue().toString());
+        if (occurrenceValue <= 0) {
+            setErrorMessage("Occurrence value must be a positive integer");
+            return Result.FAILED;
+        }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java`
around lines 46 - 47, Validate and explicitly handle the occurrence parsing and
edge cases: replace the plain Integer.parseInt(occurrence.getValue().toString())
use in StoreMatchingRegexValueInAVariableOccurrence with a guarded parse that
catches NumberFormatException (so you don't swallow it under the generic
Exception block) and then check the parsed occurrenceValue is >= 1; if the value
is non-numeric, zero, or negative, throw or return a clear validation error
(e.g., IllegalArgumentException or a step-fail with a descriptive message) so
invalid inputs don't silently produce no matches.
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java (1)

3-4: Remove unused imports.

Result and ExceptionUtils are imported but not used.

♻️ Proposed fix
 package com.testsigma.addons.web;
 
-import com.testsigma.sdk.Result;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java`
around lines 3 - 4, The imports com.testsigma.sdk.Result and
org.apache.commons.lang3.exception.ExceptionUtils are unused in the Regex class;
remove those unused import lines to clean up the file and avoid compiler/lint
warnings—locate the import block at the top of Regex.java and delete the two
import statements referencing Result and ExceptionUtils.
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java (1)

75-75: Replace System.out.println with logger for consistency.

Same issue as other platform variants—use logger.info() instead.

♻️ Proposed fix
-            System.out.println("Matched string : " + matchedString);
+            logger.info("Matched string : " + matchedString);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java`
at line 75, Replace the System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with the class logger; remove the println and call
logger.info to log the matchedString (e.g., logger.info(...)) and ensure the
class has a proper Logger instance (e.g., a private static final Logger logger =
LoggerFactory.getLogger(StoreMatchingRegexValueInAVariableOccurrence.class) or
equivalent) so logging is consistent with other platform variants.
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java (1)

58-63: Remove commented-out test harness code from production action class.

Line 58–63 is dead commented code and should be removed for maintainability.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java`
around lines 58 - 63, Remove the dead commented test-harness block (the
commented-out main method that instantiates MyFirstWebAction and calls
setTestData, setRegExPattern, and execute) from the RegExPatternMatch.java
production action class; simply delete the entire commented section so the class
contains only the production code and no leftover test scaffolding (look for the
commented "public static void main" block referencing MyFirstWebAction,
setTestData, setRegExPattern, and execute).
validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java (1)

76-76: Use framework logger instead of System.out.println.

Line 76 should use logger to keep logging consistent and controllable.

Proposed fix
-            System.out.println("Matched string : " + matchedString);
+            logger.info("Matched string stored in runtime variable '{}'", varName);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java`
at line 76, Replace the direct System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence that prints "Matched string : " +
matchedString with the framework logger (use the existing logger instance in the
class) so logs follow the project's logging strategy; call logger.info (or
logger.debug if this is verbose) and include matchedString in the log message
(use parameterized logging if supported).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java`:
- Around line 34-35: In RegExPatternMatch, avoid logging raw test payloads from
testData.getValue() and regExPattern.getValue(); replace the two
logger.info(...) calls with logging that either omits the full values (log only
that values were received or their lengths/types) or logs redacted/masked
versions (e.g., replace characters with asterisks or call a sanitize/mask helper
like maskSensitive(value)) and/or lower-severity debug without actual contents;
update references to testData.getValue() and regExPattern.getValue() accordingly
to ensure no sensitive content is written to logs.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java`:
- Around line 59-65: The catch block in StoreMatchingRegexValueInAVariable
currently logs the exception and sets an error message but leaves the local
result variable as Result.SUCCESS, causing the method to incorrectly report
success; update the catch block in the method (where
logger.debug(e.getMessage()) and setErrorMessage(...) are called) to set result
= Result.FAILED (or return Result.FAILED) and include the exception details in
the log/error message so failures are propagated correctly.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Around line 49-52: The three logger.info lines in
StoreMatchingRegexValueInAVariableOccurrence that print inputData, regexValue,
and varName must not emit raw values; replace them with either no-op or
sanitized/masked logging (e.g., log only lengths, types, or a fixed placeholder)
and/or lower the level to debug if non-sensitive telemetry is required;
specifically update the references to inputData, regexValue, and varName so the
logger does not output actual payloads (mask values, log "REDACTED" or
value.length(), or remove the logs entirely).

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java`:
- Around line 1-24: The class Regex contains a standalone main method with
hardcoded test values (Pattern/Matcher usage) that is not part of the Testsigma
addon framework; remove the main method or relocate this test code to the test
sources (e.g., unit test class) so the production class Regex only contains
framework-relevant logic, ensure you delete the main(String[] args) method and
any test-only imports/usages (Pattern/Matcher test block) from the Regex class.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexCountValue.java`:
- Around line 44-47: The logger.info calls in StoreMatchingRegexCountValue that
print inputData and regexValue expose raw payloads; replace those direct logs
with non-sensitive summaries (e.g., log only varName, lengths, a hash or masked
version of inputData and regexValue, or a boolean indicating presence) and/or
remove them entirely; update the logging lines referencing logger.info,
inputData, regexValue and varName so they do not emit raw content but instead
emit safe metadata (lengths, truncated/masked strings, or hashes) to preserve
useful info without leaking sensitive data.

---

Nitpick comments:
In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 6: Remove the unused import "com.testsigma.sdk.WebAction" from the top of
the file; the class StoreMatchingRegexValueInAVariableOccurrence already extends
AndroidAction so the WebAction import is unnecessary—delete the import line to
clean up unused dependencies.
- Line 76: Replace the direct stdout call with the class logger: in
StoreMatchingRegexValueInAVariableOccurrence where System.out.println("Matched
string : " + matchedString) is used, change it to use the class logger
(logger.info) and log the matchedString with the same message format; ensure you
reference the existing logger instance in that class and remove the
System.out.println call so logging is consistent across platform variants.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java`:
- Around line 58-63: Remove the dead commented test-harness block (the
commented-out main method that instantiates MyFirstWebAction and calls
setTestData, setRegExPattern, and execute) from the RegExPatternMatch.java
production action class; simply delete the entire commented section so the class
contains only the production code and no leftover test scaffolding (look for the
commented "public static void main" block referencing MyFirstWebAction,
setTestData, setRegExPattern, and execute).

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java`:
- Line 38: In StoreMatchingRegexValueInAVariable, rename the local variable
"Regex" to follow Java camelCase (e.g., "regex") where it's assigned from
regex.getValue().toString(), and update all subsequent usages in this
class/method (references to "Regex" later in the method) to the new name to keep
naming consistent and compile correctly.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 76: Replace the direct System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence that prints "Matched string : " +
matchedString with the framework logger (use the existing logger instance in the
class) so logs follow the project's logging strategy; call logger.info (or
logger.debug if this is verbose) and include matchedString in the log message
(use parameterized logging if supported).

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 6: Remove the unused import com.testsigma.sdk.WebAction from the top of
the file; the class StoreMatchingRegexValueInAVariableOccurrence already extends
IOSAction so WebAction is not referenced—delete the import line and run a quick
compile or organize/imports to ensure no other unused imports remain.
- Line 76: Replace the System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with logger.info(...) for consistency with other variants;
use the existing logger instance (or add a private static final Logger logger if
missing) and format the message the same way ("Matched string : " +
matchedString) so logging is consistent across platforms.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 75: Replace the direct System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with the project's logger API—use logger.info with the same
message format so logs go through the logging framework and respect log levels;
locate the print in the method where matchedString is produced and swap it to
logger.info("Matched string : " + matchedString) (or the equivalent string
formatting used elsewhere) to keep output consistent.
- Around line 46-47: Validate and explicitly handle the occurrence parsing and
edge cases: replace the plain Integer.parseInt(occurrence.getValue().toString())
use in StoreMatchingRegexValueInAVariableOccurrence with a guarded parse that
catches NumberFormatException (so you don't swallow it under the generic
Exception block) and then check the parsed occurrenceValue is >= 1; if the value
is non-numeric, zero, or negative, throw or return a clear validation error
(e.g., IllegalArgumentException or a step-fail with a descriptive message) so
invalid inputs don't silently produce no matches.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java`:
- Around line 3-4: The imports com.testsigma.sdk.Result and
org.apache.commons.lang3.exception.ExceptionUtils are unused in the Regex class;
remove those unused import lines to clean up the file and avoid compiler/lint
warnings—locate the import block at the top of Regex.java and delete the two
import statements referencing Result and ExceptionUtils.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java`:
- Around line 63-68: Remove the commented-out main method block inside the
RegExPatternMatch class (the multi-line comment that contains "public static
void main" and the MyFirstWebAction setup lines) to clean up dead code; locate
the commented snippet in RegExPatternMatch.java and delete the entire commented
section including its opening /* and closing */ so no leftover commented test
code remains.
- Around line 33-34: The code currently logs testData and regExPattern twice in
RegExPatternMatch (logger.info("Test Data::" + testData.getValue()) and
logger.info("RegEx Pattern::" + regExPattern.getValue()) appear at both sets of
lines); remove the duplicate pair so each value is logged only once (keep one
pair of logger.info calls referencing testData.getValue() and
regExPattern.getValue(), and delete the other), ensuring the logger variable and
surrounding method behavior (in RegExPatternMatch) remain unchanged.
- Around line 36-54: The local variable result in RegExPatternMatch is unused
because both branches return immediately; remove the declaration
"com.testsigma.sdk.Result result = com.testsigma.sdk.Result.SUCCESS;" and any
assignments to result (e.g., where it’s set to com.testsigma.sdk.Result.FAILED)
and instead directly return Result.FAILED in the failing branch (leave the
success branch returning Result.SUCCESS). Update the code around
Pattern.compile, Matcher matcher = pattern.matcher(...), and the if
(matcher.matches()) block accordingly to eliminate the redundant variable.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java`:
- Line 75: Replace the System.out.println call in
StoreMatchingRegexValueInAVariableOccurrence (the line printing "Matched string
: " + matchedString) with the class logger; remove the println and call
logger.info to log the matchedString (e.g., logger.info(...)) and ensure the
class has a proper Logger instance (e.g., a private static final Logger logger =
LoggerFactory.getLogger(StoreMatchingRegexValueInAVariableOccurrence.class) or
equivalent) so logging is consistent with other platform variants.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b6561a6-3de8-4e1d-a476-8819bb9d767f

📥 Commits

Reviewing files that changed from the base of the PR and between 1f8d436 and 72abba4.

📒 Files selected for processing (15)
  • validate_data_with_regex_pattern/pom.xml
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexCountValue.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/android/StoreMatchingRegexValueInAVariableOccurrence.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexCountValue.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexCountValue.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/ios/StoreMatchingRegexValueInAVariableOccurrence.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexCountValue.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/mobile_web/StoreMatchingRegexValueInAVariableOccurrence.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/RegExPatternMatch.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexCountValue.java
  • validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexValueInAVariableOccurrence.java

Comment on lines +34 to +35
logger.info("Test Data::"+testData.getValue());
logger.info("RegEx Pattern::"+regExPattern.getValue());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Do not log raw test payloads.

Line 34–35 logs raw input and regex values, which can leak sensitive test data.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/RegExPatternMatch.java`
around lines 34 - 35, In RegExPatternMatch, avoid logging raw test payloads from
testData.getValue() and regExPattern.getValue(); replace the two
logger.info(...) calls with logging that either omits the full values (log only
that values were received or their lengths/types) or logs redacted/masked
versions (e.g., replace characters with asterisks or call a sanitize/mask helper
like maskSensitive(value)) and/or lower-severity debug without actual contents;
update references to testData.getValue() and regExPattern.getValue() accordingly
to ensure no sensitive content is written to logs.

Comment on lines +59 to +65
}
catch(Exception e) {
logger.debug(e.getMessage());
setErrorMessage("Failed to perform operation "+e.getMessage()+e.getCause());
}

return result;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical bug: Method returns SUCCESS even when an exception occurs.

When an exception is caught, the error message is set but result remains Result.SUCCESS (set at line 44). The method then returns this success result, masking the failure.

🐛 Proposed fix
         catch(Exception e) {
             logger.debug(e.getMessage());
             setErrorMessage("Failed to perform operation "+e.getMessage()+e.getCause());
+            return Result.FAILED;
         }
-
-        return result;
+        return Result.SUCCESS;
     }

Or alternatively, set result = Result.FAILED in the catch block.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariable.java`
around lines 59 - 65, The catch block in StoreMatchingRegexValueInAVariable
currently logs the exception and sets an error message but leaves the local
result variable as Result.SUCCESS, causing the method to incorrectly report
success; update the catch block in the method (where
logger.debug(e.getMessage()) and setErrorMessage(...) are called) to set result
= Result.FAILED (or return Result.FAILED) and include the exception details in
the log/error message so failures are propagated correctly.

Comment on lines +49 to +52
logger.info("Input data : " + inputData);
logger.info("Regex : " + regexValue);
logger.info("Runtime variable name : " + varName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid logging raw input/regex values.

Line 49–51 logs full payload data and can leak sensitive values in execution logs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/desktop/StoreMatchingRegexValueInAVariableOccurrence.java`
around lines 49 - 52, The three logger.info lines in
StoreMatchingRegexValueInAVariableOccurrence that print inputData, regexValue,
and varName must not emit raw values; replace them with either no-op or
sanitized/masked logging (e.g., log only lengths, types, or a fixed placeholder)
and/or lower the level to debug if non-sensitive telemetry is required;
specifically update the references to inputData, regexValue, and varName so the
logger does not output actual payloads (mask values, log "REDACTED" or
value.length(), or remove the logs entirely).

Comment on lines +1 to +24
package com.testsigma.addons.web;

import com.testsigma.sdk.Result;
import org.apache.commons.lang3.exception.ExceptionUtils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Regex
{
public static void main(String[] args) {
try {
Pattern pattern = Pattern.compile("^[A-Za-z]+$");
Matcher matcher = pattern.matcher("HelloWorld");
if (matcher.matches()) {
System.out.println("The input string matches the pattern.");
} else {
System.out.println("The input string does not match the pattern.");
}
} catch (Exception error) {
System.out.println("Exception occurred while executing the action::" + error.getMessage());
}
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

This appears to be test/debug code—consider removing.

This standalone main method class with hardcoded values doesn't integrate with the Testsigma addon framework and seems to serve no production purpose. If this was used for local testing, it should be removed or moved to the test directory.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/Regex.java`
around lines 1 - 24, The class Regex contains a standalone main method with
hardcoded test values (Pattern/Matcher usage) that is not part of the Testsigma
addon framework; remove the main method or relocate this test code to the test
sources (e.g., unit test class) so the production class Regex only contains
framework-relevant logic, ensure you delete the main(String[] args) method and
any test-only imports/usages (Pattern/Matcher test block) from the Regex class.

Comment on lines +44 to +47
logger.info("Input data : " + inputData);
logger.info("Regex : " + regexValue);
logger.info("Runtime variable name : " + varName);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid logging raw input and regex content.

Line 44–46 logs full payloads. This can expose sensitive data in execution logs.

Proposed fix
-        logger.info("Input data : " + inputData);
-        logger.info("Regex : " + regexValue);
-        logger.info("Runtime variable name : " + varName);
+        logger.info("Regex match count request received. inputLength=" + inputData.length()
+                + ", runtimeVariable=" + varName);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
logger.info("Input data : " + inputData);
logger.info("Regex : " + regexValue);
logger.info("Runtime variable name : " + varName);
logger.info("Regex match count request received. inputLength=" + inputData.length()
", runtimeVariable=" + varName);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@validate_data_with_regex_pattern/src/main/java/com/testsigma/addons/web/StoreMatchingRegexCountValue.java`
around lines 44 - 47, The logger.info calls in StoreMatchingRegexCountValue that
print inputData and regexValue expose raw payloads; replace those direct logs
with non-sensitive summaries (e.g., log only varName, lengths, a hash or masked
version of inputData and regexValue, or a boolean indicating presence) and/or
remove them entirely; update the logging lines referencing logger.info,
inputData, regexValue and varName so they do not emit raw content but instead
emit safe metadata (lengths, truncated/masked strings, or hashes) to preserve
useful info without leaking sensitive data.

@akhil-testsigma akhil-testsigma merged commit 3e98439 into dev Mar 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants