Skip to content

Deprecate unused function frmFrontForm.escapeHtml#2178

Merged
Crabcyborg merged 1 commit into
masterfrom
deprecate_unused_function_frmFrontForm.escapeHtml
Dec 10, 2024
Merged

Deprecate unused function frmFrontForm.escapeHtml#2178
Crabcyborg merged 1 commit into
masterfrom
deprecate_unused_function_frmFrontForm.escapeHtml

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg commented Dec 10, 2024

I found this being used in old v2.0 code. But it hasn't been used since v3.0+.

@Crabcyborg Crabcyborg added this to the 6.17 milestone Dec 10, 2024
@Crabcyborg Crabcyborg merged commit 8330718 into master Dec 10, 2024
@Crabcyborg Crabcyborg deleted the deprecate_unused_function_frmFrontForm.escapeHtml branch December 10, 2024 21:02
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 10, 2024

Walkthrough

The pull request introduces significant changes to the frmFrontFormJS function in js/formidable.js, primarily enhancing form validation and submission handling. Key modifications include the deprecation of the escapeHtml, invisible, and visible functions, alongside updates to the validateFieldValue, checkEmailField, and checkPasswordField functions to incorporate an onSubmit parameter. The getAjaxFormErrors function now allows for custom error handling, and the submitFormManual function has been refined to check for invisible reCAPTCHA. These changes modernize the codebase and improve user experience.

Changes

File Change Summary
js/formidable.js - Updated validateFieldValue, checkEmailField, and checkPasswordField to include onSubmit parameter.
- Deprecated escapeHtml, invisible, and visible functions.
- Modified getAjaxFormErrors to call frmThemeOverride_jsErrors.
- Refined submitFormManual to check for invisible reCAPTCHA and improved loading indicator handling.

Possibly related PRs

Suggested labels

action: needs qa

Suggested reviewers

  • AbdiTolesa
  • garretlaxton

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@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: 0

🧹 Outside diff range and nitpick comments (1)
js/formidable.js (1)

1945-1945: Update deprecation message with the correct version number

The console.warn statement in the escapeHtml function uses a placeholder 'vx.x' for the version number. Please update it to the actual version (e.g., 'v6.16.3') for consistency and clarity in deprecation notices.

Apply this diff to correct the version number:

-    console.warn( 'DEPRECATED: function frmFrontForm.escapeHtml in vx.x' );
+    console.warn( 'DEPRECATED: function frmFrontForm.escapeHtml in v6.16.3' );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6ea95b1 and 0dcfab4.

📒 Files selected for processing (1)
  • js/formidable.js (1 hunks)
🔇 Additional comments (4)
js/formidable.js (4)

Line range hint 1960-1963: Consider removing the deprecated invisible function if it's no longer used

The invisible function has been marked as deprecated and logs a warning. If it's obsolete and no longer used, consider removing it to clean up the codebase. If it needs to stay for compatibility, ensure the deprecation is well-documented.

Run the following script to check for any remaining usages of invisible:


Line range hint 807-839: Verify that all calls to validateFieldValue pass the new onSubmit parameter

The validateFieldValue function has been updated to include the new onSubmit parameter. Ensure that all function calls to validateFieldValue are updated accordingly to prevent unexpected behavior during form validation.

Run the following script to identify any calls to validateFieldValue that may not have been updated:


Line range hint 1944-1952: Consider removing the deprecated escapeHtml function if it's no longer used

The escapeHtml function has been marked as deprecated and logs a warning. If this function is no longer used in the codebase, consider removing it to simplify the code. If it must remain for backward compatibility, ensure its deprecation is properly documented and plan for its removal in future versions.

Run the following script to check for any remaining usages of escapeHtml:

✅ Verification successful

Remove the deprecated and unused escapeHtml function

Based on the comprehensive search results, the escapeHtml function appears to be defined in js/formidable.js but has no active usage in the codebase. The function is already marked as deprecated with a console warning, and our thorough search using various patterns couldn't find any calls to this function. It's safe to remove this unused code.

  • Remove the escapeHtml function from js/formidable.js (lines 1941-1947)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of the deprecated 'escapeHtml' function.
# Expect: No matches if the function is no longer used.

rg 'escapeHtml\('

Length of output: 19


Script:

#!/bin/bash
# Let's try a more comprehensive search for escapeHtml usage
# 1. Search for the function name without parentheses
# 2. Search for the function name as a property/method
# 3. Include some context lines for better understanding

rg -i "escapehtml" -A 2

# Also search in the AST for function calls
ast-grep --pattern 'escapeHtml($_)'

# And search for the function definition to understand its context better
ast-grep --pattern 'escapeHtml: function($_) { $$$ }'

Length of output: 7333


Script:

#!/bin/bash
# Let's search for any actual calls to escapeHtml in the codebase
# Using different variations to ensure we catch all uses

# Search for direct function calls
rg -i "\.escapeHtml\(" -A 2

# Search for variable assignments or references
rg -i "= escapeHtml" -A 2

# Search for the function name in object destructuring
rg -i "\{.*escapeHtml.*\}" -A 2

Length of output: 91


Line range hint 1970-1973: Consider removing the deprecated visible function if it's no longer used

The visible function has been marked as deprecated and logs a warning. If it's no longer necessary, consider removing it to reduce code clutter. If retaining it for compatibility, ensure its deprecation status is clearly documented.

Run the following script to check for any remaining usages of visible:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant