Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate R File Formatting #3413

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Sweetdevil144
Copy link
Contributor

Description

Fixes #3280 (Styler Section)
This PR introduces a new script, format.sh, designed to automate the formatting of all .R files within the PEcAN repository using the styler package. The script performs the following functions:

  1. Tracking Formatted Files:
    Maintains a formatted.csv file that logs each formatted R script's relative path, its MD5 hash, and the timestamp of the last formatting. This ensures that only new or modified files are formatted in subsequent runs.

  2. Formatting Process:

    • Initial Run: Formats all existing .R files and records their hashes and timestamps.
    • Subsequent Runs:
      • New Files: Automatically formats and adds them to the tracking file.
      • Modified Files: Detects changes via MD5 hash comparison, re-formats them, and updates the tracking file.
      • Unchanged Files: Skips formatting to optimize performance.
  3. Roxygen Documentation:
    After formatting, the script runs make document to update all roxygen-based documentation, ensuring that documentation remains consistent with the latest code changes.

Motivation and Context

I myself was frustrated a bit on discovering extended formatting issues while working on workflow.R.
Maintaining consistent code formatting across a large repository like PEcAN enhances readability, reduces merge conflicts, and enforces coding standards. Manually formatting and tracking changes in numerous .R files can be time-consuming and error-prone.

This automation facilitates a more streamlined development workflow, allowing contributors to focus on functionality rather than manual formatting tasks.

Review Time Estimate

  • Immediately
  • Within one week
  • When possible

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • My change requires a change to the documentation.
  • My name is in the list of CITATION.cff
  • I agree that PEcAn Project may distribute my contribution under any or all of
    • the same license as the existing code,
    • and/or the BSD 3-clause license.
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature : Automated linting for files
1 participant