Skip to content

Fix #749, typographical errors - #746

Open
JAuriac wants to merge 10 commits into
pdidev:mainfrom
JAuriac:trailingAndSpelling
Open

JAuriac wants to merge 10 commits into
pdidev:mainfrom
JAuriac:trailingAndSpelling

Conversation

@JAuriac

@JAuriac JAuriac commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Add github action for typographical errors

List of things to check before making a PR

Before merging your code, please check the following:

  • you have added a line describing your changes to the Changelog;
  • you have added unit tests for any new or improved feature;
  • in case you updated dependencies, you have checked pdi/docs/CheckList.md;
  • in case of a change in pdi.h, this same change must be reflected in mock_pdi/pdi.h;
  • in case of a new plugin, make sure the plugin issues the corresponding timer events;
  • you have checked your code format:
    • you have checked that you respect all conventions specified in CONTRIBUTING.md;
    • you have checked that the indentation and formatting conforms to the .clang-format;
    • you have documented with doxygen any new or changed function / class;
  • you have correctly updated the copyright headers:
    • your institution is in the copyright header of every file you (substantially) modified;
    • you have checked that the end-year of the copyright there is the current one;
  • you have updated the AUTHORS file:
    • you have added yourself to the AUTHORS file;
    • if this is a new contribution, you have added it to the AUTHORS file;
  • you have added everything to the user documentation:
    • any new CMake configuration option;
    • any change in the yaml config;
    • any change to the public or plugin API;
    • any other new or changed user-facing feature;
    • any change to the dependencies;
  • you have correctly linked your MR to one or more issues:
    • your MR solves an identified issue;
    • your commit contain the Fix #issue keyword to autoclose the issue when merged.

@JAuriac
JAuriac force-pushed the trailingAndSpelling branch 2 times, most recently from f8a9110 to 2be1551 Compare August 31, 2026 09:25
@JAuriac
JAuriac marked this pull request as ready for review August 31, 2026 11:59
@JAuriac
JAuriac requested a review from a team August 31, 2026 11:59
@JAuriac

JAuriac commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

The only three files to review on this PR are :
.github/workflows/tests.yml, to use the 'typos' github action (similarly to ddc)
.typos.toml, to define exceptions for the 'typos' action
bin/test_indent, to handle removing trailing whitespaces and checking for correct newline at end of file
All the other files modified are typographical errors fixes

@JAuriac JAuriac linked an issue Sep 4, 2026 that may be closed by this pull request
@JAuriac
JAuriac force-pushed the trailingAndSpelling branch from 3534fbd to c58d9fa Compare September 4, 2026 08:47
Comment thread .github/workflows/tests.yml Outdated
Comment on lines +41 to +45
spell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: crate-ci/typos@v1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks. This is quite useful for better code.
Could this be merged into the indent check?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes it could, they are left separated for now as to not extend the indent requirement over the rest of the CI (cf. "needs: second")
Should we merge those ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest incorporating typo checking inside indent, which will be the very first step of the CI workflow. Other CI steps will start only when the needs succeed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, change made
Another way to proceed would be to check this indent job last (first -> second -> rest of feature tests -> indent), as a way to the feature on all CI runs, and maybe only fix the indent step once the feature is ready to be merged

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, change made Another way to proceed would be to check this indent job last (first -> second -> rest of feature tests -> indent), as a way to the feature on all CI runs, and maybe only fix the indent step once the feature is ready to be merged

I think it is not optimal. In a case where only indent is not satisfied, CI will go through all tests -> indent to bring up the indent error. Then we fix the indent and the CI goes again with all tests -> indent to complete the cycle.
With the current setup, all tests will run only once, thus much cheaper

Comment thread .typos.toml Outdated
extend-exclude = [
"vendor/",
"pdi/docs/_template/",
"pdi/tests/PDI_expression.cxx",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this file excluded?

@JAuriac JAuriac Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It contains a test which itself checks for spelling mistake through dedicated lists, for example :
const vector<string> v_fpos{"y1", "YY", "yEs", "Yess", "YE5", "tru", "TrUe", "TRRUE", "onn", "0n", "ONN"};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see.
When looking at the cxx file, at the very last part, this section

for (auto&& string_value: v_fneg) {
...
ASSERT_EQ(PDI::Expression(string_value).to_long(context_mock), 1);

appears strange to me. Shouldn't it be comparing to 0 instead of 1?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems those values aren't required :

long Expression::Impl::String_literal::to_long(Context& ctx) const

and that we need :
EXPECT_THROW(PDI::Expression(string_value).to_long(context_mock), PDI::Error);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made PR #754 for issue #753 to fix this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

isn't there a way to exclude specific lines with a comment in the file instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

#746 (comment)
Added option to use specific comment to mark some lines or some code block as ignored by the 'typos' check

Comment thread CHANGELOG.md Outdated
Comment thread pdi/docs/Source_installation.md
Comment thread pdi/docs/Using_PDI.md
Comment thread bin/test_indent Outdated
Comment on lines +80 to +85

git ls-files -z | grep -zZv '^vendor/' | while IFS= read -r -d '' file; do
if [ -f "$file" ] && file --mime-type "$file" | grep -q 'text/'; then
sed -i -e 's/[ \t]*$//' -e '$a\' "$file"
fi
done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is to ensure having a line break at the end of each file, to prevent the issue of a line of code shown as modified through git if later another line is appended at the end of the file (also, this is required by the C standard)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/CExA-project/ddc/blob/main/bin/newline_at_eof.py
Another PR will be dedicated to this, removing this change for this PR

Comment thread bin/test_indent Outdated
@JAuriac
JAuriac force-pushed the trailingAndSpelling branch from c58d9fa to 86cd651 Compare September 4, 2026 14:30
Comment thread README.md Outdated
PC_tree_t data_name = PC_get(data_item, "{0}");
PC_tree_t datas = PC_get(data_item, ".%s", to_string(data_name).c_str());
opt_each(datas, [&](PC_tree_t one_data) {
PC_tree_t data = PC_get(data_item, ".%s", to_string(data_name).c_str());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm all in favor of fixing the doc & comments, but I'm not sure fixing the code with this is a very good idea. I'm afraid it might generate subtle bugs later.

Some variables might use a non English names because the correct English name is already used for something else. By "fixing" that, one might shadow the other variable & change behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ideally, wouldn't this issue be fixed by using more verbose variables names ?
Incidentally, relying on specific spellings would expose us to future discrepancies

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree to check spelling for documentation and comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

A new commit now changes the behaviour of the CI step to only issue warnings

@jbigot jbigot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks good overall

@jbigot jbigot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good idea, but the end-of-line space check needs rework

Comment thread bin/test_indent Outdated
Comment on lines +81 to +85
git ls-files -z | grep -zZv '^vendor/' | while IFS= read -r -d '' file; do
if [ -f "$file" ] && file --mime-type "$file" | grep -q 'text/'; then
sed -i -e 's/[ \t]*$//' -e '$a\' "$file"
fi
done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

beware, this breaks the test completely!

The exit-code checked to verify if everything went fine in the CI used to be that of the last executed command, the clang-format one.

Now this comes after and completely discards the indentation test.

In addition, this does not work as a test and will never detect a typo. The last command is the loop command that has no reason to fail.

It does also not follow the logic of the command, it always applies the change, whether the --apply flag is passed or not.

Minor issues, but this uses GNU-specific sed extensions, I expect this to fail on MacOS.

Very minor issue, if any directory contains text/ in its path, everything below it will be checked.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/CExA-project/ddc/blob/main/bin/newline_at_eof.py
Another PR will be dedicated to this, removing this change for this PR

Comment thread .typos.toml
Comment on lines +8 to +12
[default.extend-words]
ND = "ND"
iy = "iy"
iz = "iz"
cpy = "cpy"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's this about?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Those are considered typos by the tool, but not by us, so we define exceptions
"ND" designates N-dimensional arrays, and is a keyword mirroring "ndarray"
"iy" and "iz" are coordinates along specific dimensions (note that "ix", or "ny", "sy", "ry" are not caught by the tool)
"cpy" is mirroring the frequently used keyword of copy related to GPU use

Comment thread .typos.toml Outdated
extend-exclude = [
"vendor/",
"pdi/docs/_template/",
"pdi/tests/PDI_expression.cxx",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

isn't there a way to exclude specific lines with a comment in the file instead?

Comment thread CHANGELOG.md Outdated
@JAuriac

JAuriac commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

#746 (comment)
Added option to use specific comment to mark some lines or some code block as ignored by the 'typos' check

@JAuriac JAuriac changed the title Trailing whitespaces & typographical errors Typographical errors Sep 8, 2026
@JAuriac JAuriac changed the title Typographical errors Fix #749, typographical errors Sep 8, 2026
Comment thread CHANGELOG.md Outdated
Comment thread .typos.toml

@jmorice91 jmorice91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the puil_request_template.md, add a line for the typos CI tools as indent.

Comment thread .github/workflows/tests.yml
Comment thread bin/test_indent Outdated
Comment thread CHANGELOG.md Outdated
@JAuriac
JAuriac force-pushed the trailingAndSpelling branch from 5dad2c0 to 6d2580c Compare September 24, 2026 12:39
@JAuriac
JAuriac requested a review from jmorice91 September 24, 2026 13:07

@iole-bolognesi iole-bolognesi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good, I agree with Yushan's comment that it would be useful to add the ignore options to the How_to_create_plugin.md

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.

Add 'typos' action to github CI workflow

5 participants