Skip to content

Add Missing Strings Validation for Moodle Plugin CI #356

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

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

Conversation

volodymyrdovhan
Copy link

Summary

  • Add a comprehensive language string validation tool for Moodle plugins
  • Validates required strings, detects missing/unused strings from PHP, JavaScript, templates, and database files
  • Includes automatic subplugin discovery and validation

What It Checks

Code Usage

  • get_string() and new lang_string() calls in PHP
  • JavaScript string methods (str.get_string(), str.get_strings(), getString(), getStrings(), Prefetch methods)
  • Mustache template strings ({{#str}}, {{#cleanstr}})
  • Help button strings (->addHelpButton())
  • Dynamic strings automatically filtered (variables like $row->state are ignored)

Plugin Requirements

  • All plugins: pluginname
  • Activity modules: modulename, modulenameplural
  • Database files: capabilities, caches, messages, tags, mobile addons, subplugins
  • Class implementations: Privacy providers, search areas, grade items, exceptions

Subplugin Support

  • Automatic discovery: Reads db/subplugins.json and db/subplugins.php
  • Recursive validation: Validates main plugin + all discovered subplugins

Usage

# Basic validation
moodle-plugin-ci missingstrings /path/to/plugin

Copy link

codecov bot commented Jun 23, 2025

Codecov Report

Attention: Patch coverage is 81.71429% with 416 lines in your changes missing coverage. Please review.

Project coverage is 85.06%. Comparing base (d5e4885) to head (dcd824a).

Files with missing lines Patch % Lines
src/MissingStrings/Checker/CheckerUtils.php 64.73% 61 Missing ⚠️
src/MissingStrings/FileDiscovery/FileDiscovery.php 50.00% 54 Missing ⚠️
...ssingStrings/Extractor/MustacheStringExtractor.php 51.81% 53 Missing ⚠️
...hecker/ClassMethodChecker/AbstractClassChecker.php 74.80% 33 Missing ⚠️
src/MissingStrings/ValidationResult.php 70.00% 27 Missing ⚠️
...rc/MissingStrings/Discovery/SubpluginDiscovery.php 78.76% 24 Missing ⚠️
...er/DatabaseFileChecker/AbstractDatabaseChecker.php 56.52% 20 Missing ⚠️
src/MissingStrings/Cache/FileContentCache.php 60.00% 18 Missing ⚠️
src/MissingStrings/StringValidator.php 91.66% 18 Missing ⚠️
...cker/ClassMethodChecker/PrivacyProviderChecker.php 82.29% 17 Missing ⚠️
... and 14 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #356      +/-   ##
============================================
- Coverage     88.31%   85.06%   -3.25%     
- Complexity      761     1637     +876     
============================================
  Files            77      114      +37     
  Lines          2344     4619    +2275     
============================================
+ Hits           2070     3929    +1859     
- Misses          274      690     +416     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@volodymyrdovhan volodymyrdovhan force-pushed the feature/missing-strings-validator branch 4 times, most recently from 94f10f2 to dd9f119 Compare June 23, 2025 22:54
- Add a comprehensive language string validation tool for Moodle plugins
- Validates required strings, detects missing/unused strings from PHP, JavaScript, templates, and database files
- Includes automatic subplugin discovery and validation
@volodymyrdovhan volodymyrdovhan force-pushed the feature/missing-strings-validator branch from dd9f119 to 8817822 Compare June 23, 2025 23:06
@kabalin
Copy link
Member

kabalin commented Jun 24, 2025

Wow, that is the biggest PR to this project I have ever seen! 🥇Well done @volodymyrdovhan, missing strings check definitely would be useful to have.

Do you have some performance info, it is fast on projects with numerous strings?

@volodymyrdovhan volodymyrdovhan force-pushed the feature/missing-strings-validator branch 3 times, most recently from 84f6082 to dcd824a Compare June 25, 2025 11:03
@volodymyrdovhan volodymyrdovhan force-pushed the feature/missing-strings-validator branch from dcd824a to 6609072 Compare June 25, 2025 13:31
@volodymyrdovhan
Copy link
Author

Hi @kabalin,
I added some validation stats to display with the --debug option.

image

Here are some stats for some Moodle core plugins.

mod/assign:

  • Total processing time: 1.829 seconds
  • Plugins processed: 8
    • Main: 1, Subplugins: 7
  • Files processed: 842
  • String processing metrics:
    • Defined strings: 842
    • Required strings: 10
    • Strings extracted: 1025
    • String usages found: 1268

mod/quiz

  • Total processing time: 1.664 seconds
  • Plugins processed: 15
    • Main: 1, Subplugins: 14
  • Files processed: 887
  • String processing metrics:
    • Defined strings: 1545
    • Required strings: 17
    • Strings extracted: 1109
    • String usages found: 1230

mod/lesson

  • Total processing time: 0.995 seconds
  • Plugins processed: 1
  • Files processed: 160
  • String processing metrics:
    • Defined strings: 571
    • Required strings: 3
    • Strings extracted: 605
    • String usages found: 736

mod/bigbluebuttonbn/

  • Total processing time: 1.180 seconds
  • Plugins processed: 1
  • Files processed: 328
  • String processing metrics:
    • Defined strings: 561
    • Required strings: 3
    • Strings extracted: 522
    • String usages found: 538

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