-
Notifications
You must be signed in to change notification settings - Fork 27
Add linter to ensure no tabs in animint.js #257
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
Conversation
Adds CI workflow and R test to catch tab characters. JavaScript should use spaces, not tabs for indentation. Fixes #256
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #257 +/- ##
===========================================
+ Coverage 77.71% 95.37% +17.65%
===========================================
Files 164 1 -163
Lines 8788 2788 -6000
Branches 562 574 +12
===========================================
- Hits 6830 2659 -4171
+ Misses 1958 129 -1829
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
tests/testthat/test-linter-no-tabs.R
Outdated
| @@ -0,0 +1,20 @@ | |||
| test_that("animint.js contains no tab characters", { | |||
| animint_js_path <- system.file("htmljs", "animint.js", package = "animint2") | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add mustWork=TRUE
|
Sir Thank a lot for the suggestion! I looked into using lintr as you recommended. However, lintr is specifically designed for linting R code, not JavaScript files. Since we're checking inst/htmljs/animint.js (a JavaScript file) for tabs, using lintr would require creating a complex custom linter that reads non-R files, which seems like overkill for this simple check. The current grep-based approach:- Would you be okay with keeping the simple grep approach in .github/workflows/check-tabs.yml and removing the redundant R test file entirely as you mentioned ? This gives us the CI protection you want without unnecessary complexity. The https://github.com/Rdatatable/data.table/blob/master/.github/workflows/code-quality.yaml Sir if you want to add some feedback or correct me if I am wrong in any way of my understanding. |
|
please avoid cross-posting (you wrote the same comment in #256 ). can you please push a commit which adds a tab to animint.js, so we can see that the test would correctly fail in that case? |
Added a tab character to line 1 of animint.js to demonstrate that the check-tabs workflow correctly detects and fails when tabs are present. This commit should result in a failed CI check.
Removed the tab character from line 1 of animint.js to demonstrate that the check-tabs workflow correctly passes when no tabs are present. This commit should result in a successful CI check (green checkmark).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove test-linter-no-tabs.R
As requested by @tdhock, removing test-linter-no-tabs.R to avoid redundancy. The GitHub Actions workflow check-tabs.yml already provides the necessary linting for tabs in animint.js.
|
Root cause: The test ❌ R_coverage fails due to pre-existing GitHub API permissions issue Sir should I proceed with this PR as-is, or would you like me to investigate the ghpages test issue separately in a different PR? |
|
when there is a ghpages test failure that is typically a false positive, which we can ignore. |
|
great thanks |
This PR adds two checks to prevent tabs from being introduced into
inst/htmljs/animint.js:.github/workflows/check-tabs.yml) - Fails CI if tabs are detectedtests/testthat/test-linter-no-tabs.R) - Tests during package checksTesting
Tested locally by:
Verified no tabs in source:
Installed package and ran test (should pass):
The test correctly detects when tabs are present and passes when they're removed.
Files Changed
.github/workflows/check-tabs.yml- New CI workflowtests/testthat/test-linter-no-tabs.R- New R testFixes #256