Skip to content

style: fix two wrong @file tags and convert leading tab indentation to spaces - #8011

Merged
mohanchen merged 2 commits into
deepmodeling:developfrom
Critsium-xy:chore/code-quality-easy-fixes
Sep 30, 2026
Merged

mohanchen merged 2 commits into
deepmodeling:developfrom
Critsium-xy:chore/code-quality-easy-fixes

Conversation

@Critsium-xy

@Critsium-xy Critsium-xy commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

Reminder

  • I have read AGENTS.md and docs/developers_guide/agent_governance.md.
  • I have linked an issue or explained why this PR does not need one.
  • I have added adequate unit tests and/or case tests, or explained why not.
  • I have listed the exact verification commands run and their results.
  • I have described user-visible behavior changes, including INPUT parameter changes.
  • I have explained core-module impact for ESolver, HSolver, ElecState, Hamilt, Operator, Psi, or other source/ changes.
  • I have requested any needed governance exception below.

Linked Issue

No issue; this is hygiene found by running
tools/03_code_analysis/code_quality_score.py over the whole source/ tree.
Happy to open a tracking issue if maintainers prefer one.

Unit Tests and/or Case Tests for my changes

No test is added: no behaviour changes. Apart from two comment lines, the whole
diff is whitespace. What matters is the evidence that nothing
else moved.

Commands run

# the scan that produced the two findings
python3 tools/03_code_analysis/code_quality_score.py source/ --format json -o cq.json

# the conversion
expand -i -t4 <file>          # for each of the 286 selected files

# proof that only whitespace moved
git diff -w --stat            # -> empty

# compile check (Linux, 15 cores, Libxc 7.1.2, LibRI 2.1.1)
cmake -B build -G Ninja -DBUILD_TESTING=OFF -DENABLE_LCAO=ON -DENABLE_MPI=ON \
      -DENABLE_OPENMP=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON
cmake --build build -j15 -- -k 0

python3 tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD

Result summary

  • git diff -w --stat is empty: not one non-whitespace character changed
    anywhere in the 246-file whitespace commit.
  • Of the 42 raw string literals in the changed files (222 lines, all in
    source_io/module_parameter/read_inp_out.cpp), none has a line this PR
    touches
    . Leading whitespace inside R"(...)" is part of the string, so that
    was the one place where rewriting leading whitespace could have changed
    behaviour.
  • No changed line follows a line ending in a backslash, so no
    backslash-continued string literal is affected either.
  • No file gained a CR.
  • Compile: 817 of 820 targets built. The 3 that failed
    (module_bse/hamilt_bse.cpp, esolver_factory.cpp,
    esolver_lr_lcao_bse.cpp) all stop at
    fatal error: RI/physics/LR.h: No such file or directory. That header is
    absent from the LibRI 2.1.1 copy on this machine, which ships only
    Exx.h/GW.h/RPA.h. The same three targets fail identically on the
    unpatched baseline
    , which I confirmed by reverting source/ and rebuilding
    them — so this is an environment gap, not a regression from this PR.
  • Governance checker: no blockers; two warnings, both answered below.

Checks not run, with reason

  • The Check documentation consistency step (regenerate docs/parameters.yaml
    and diff) was not run locally: the local build could not link an executable
    because of the LibRI gap above. This PR touches
    source_io/module_parameter/read_inp_out.cpp, but only outside its raw string
    literals, so the generated docs cannot change. CI's own doc-consistency step is
    the authoritative check and will confirm it.
  • No integration or unit test run: nothing executable changed.

What's changed?

1. Two @file tags that name a file which does not exist. Doxygen then
attributes the block to the wrong file, or to none.

file @file said
source_base/ndarray.h NDArray.h
source_lcao/module_rt/band_energy.h bandenegy.h (also a typo)

The scorer's doc_file_mismatch rule originally flagged a third file,
source_pw/module_pwdft/radial_proj.h (said radial_projection.h). #8007 has
since moved that header to source_pw/module_proj/radial_proj.h with the tag
already corrected, so it was dropped from this PR on rebase.

2. Leading tab indentation converted to spaces in 246 files.
.editorconfig has required indent_style = space with indent_size = 4 for
the whole repository, yet 339 files under source/ still indent with tabs
(18,846 lines). expand -i -t4 rewrites the initial whitespace of a line and
nothing else.

Three groups were deliberately left out:

Effect on code_quality_score.py over source/: average 82.15 -> 82.58,
passing files 1560 -> 1562, 204 files up and 6 down.

The 6 that go down lose 1 to 3 points, all through line_too_long, because the
scorer counts a tab as one character while it renders as up to four columns.
Those lines were already past 120 columns on screen; the tab was hiding it. One
of them, module_ri/exx_abfs_ctor_orbs.cpp, moves from 60 to 59 and so slips
just under the tool's pass line. Wrapping those lines would mean editing code in
a commit that is otherwise whitespace-only, so I left it for a follow-up rather
than muddy the diff.

Reviewers: git diff -w on this branch is empty, so reviewing with
git diff -w or GitHub's "Hide whitespace changes" shows only the two
comment lines from the first commit.

Rebase notes

The branch has been rebased onto develop four times to resolve conflicts with PRs
merged in the meantime (#8000, #8007, #8012, #8023, #8025, #8026, #7924, #8043 and others). Because the
second commit is whitespace-only, conflicts were not merged by hand: each
conflicting file was taken from develop as-is and expand -i -t4 was run on
it again. After the latest rebase (base 43a4a2afb):

  • git diff -w --stat upstream/develop lists only ndarray.h and
    band_energy.h (one comment line each);
  • none of the 248 changed files (246 whitespace + 2 comment) has a leading tab
    left; git ls-files --eol reports all of them as i/lf w/lf, and no added
    line ends in CR;
  • read_inp_out.cpp (the only changed file with raw string literals) was
    changed on develop again (Update out_stru parameter and its output context #8026, feat(xc): add gga_grad 1/2 with variationally consistent mode 2 #7924), so the raw-string check was re-run
    on the rebased file: 42 literals covering 222 lines, 47 lines changed by this PR,
    overlap none; no changed line follows a backslash-continued line;
  • PYTHONUTF8=1 python tools/03_code_analysis/agent_governance_check.py --base upstream/develop --head HEAD --format text
    exits 0 with no errors; its warnings are the INPUT-docs warning answered
    below plus "new default parameters" warnings on existing declarations
    (e.g. blas_connector.h) whose lines were only re-indented.

The full compile check above was run before the rebases; CI builds the rebased
branch.

Governance Notes

  • INPUT/docs changes: none. The governance checker raises an INPUT
    documentation warning because source_io/module_parameter/read_inp_out.cpp is
    in the diff, but no Input_Item registration, annotation, description,
    default_value or availability changes. The parameter descriptions in that
    file live inside R"(...)" raw string literals, and none of the 222 lines
    covered by those literals is touched by this PR, so docs/parameters.yaml and
    docs/advanced/input_files/input-main.md need no regeneration.
  • Core module impact: none. No declaration, definition, signature or control
    flow changes anywhere. ESolver, HSolver, ElecState, Hamilt, Operator and Psi
    are affected only by the indentation of lines in files they own.
  • Exceptions requested: none.

🤖 Generated with Claude Code

@mohanchen mohanchen added Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0 labels Sep 24, 2026
@Critsium-xy
Critsium-xy force-pushed the chore/code-quality-easy-fixes branch 3 times, most recently from 1eb5da4 to 0994301 Compare September 27, 2026 10:29
@Critsium-xy Critsium-xy changed the title style: fix three wrong @file tags and convert leading tab indentation to spaces style: fix two wrong @file tags and convert leading tab indentation to spaces Sep 27, 2026
@Critsium-xy
Critsium-xy force-pushed the chore/code-quality-easy-fixes branch from 0994301 to 9b0627e Compare September 28, 2026 05:31
Critsium-xy and others added 2 commits September 30, 2026 09:33
Doxygen's @file takes the name of the file it documents. These two
name a file that does not exist, so Doxygen attributes the block to the
wrong (or to no) file:

  source_base/ndarray.h                  said NDArray.h
  source_lcao/module_rt/band_energy.h    said bandenegy.h (also a typo)

Found by tools/03_code_analysis/code_quality_score.py (rule
doc_file_mismatch). The scan also flagged
source_pw/module_pwdft/radial_proj.h (said radial_projection.h), but
deepmodeling#8007 has since moved that header to source_pw/module_proj/ with the
tag already corrected, so it is no longer part of this commit.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
.editorconfig has required `indent_style = space` with `indent_size = 4`
for the whole repository, but 339 files under source/ still indent with
tabs. This converts the leading whitespace of 246 of them.

253 files were selected when this was prepared. Since then, develop has
deleted two of them and already converted five others, which leaves 246:

  - deleted: source_lcao/setup_dm.h (deepmodeling#8000),
    source_pw/module_stodft/hamilt_sdft_pw.cpp (deepmodeling#8012);
  - already converted: source_base/module_out/binstream.{h,cpp} (deepmodeling#8025),
    source_pw/module_stodft/sto_hamilt_pw.h (renamed from
    hamilt_sdft_pw.h in deepmodeling#8012), source_io/module_ctrl/ctrl_output_pw.h
    and source_pw/module_pwdft/op_pw_nl.cpp (deepmodeling#8043).

Files that develop moved are converted at their new path, e.g.
onsite_proj_tools_stress.cpp is now under source_pw/module_proj/
(deepmodeling#8007).

Scope. Three groups were deliberately left out:

  - 48 files touched by the pull requests open at the time of writing
    (deepmodeling#8000, deepmodeling#7924, deepmodeling#7906, deepmodeling#8005 and others), so this does not force a
    conflict on work in flight;
  - 5 vendored files: source_base/libm/ is ported from glibc-2.36 and
    carries its own LICENCE, and source_base/mcd.c is Softpixel
    MemCheckDeluxe under a BSD licence. Reformatting vendored sources
    makes future syncs with their upstream harder;
  - tabs that appear after the first non-blank character (alignment
    tabs, 1193 lines). Only leading indentation is converted.

Method and verification. `expand -i -t4`, which rewrites the initial
whitespace of a line and nothing else, followed by three checks:

  - `git diff -w --stat` is empty, so not one non-whitespace character
    changed anywhere in the diff;
  - of the 42 raw string literals in the changed files (222 lines, all
    in source_io/module_parameter/read_inp_out.cpp), none has a line
    that this commit touches. Leading whitespace inside `R"(...)"` is
    part of the string, so that was the one place a leading-whitespace
    rewrite could have changed behaviour;
  - no changed line follows a line ending in a backslash, so no
    backslash-continued string literal is affected either;
  - no file gained a CR.

Effect on tools/03_code_analysis/code_quality_score.py: average score
over source/ goes from 82.15 to 82.58 and the number of passing files
from 1560 to 1562.

Six files score 1 to 3 points lower, all through the `line_too_long`
rule, because the scorer counts a tab as a single character while it
renders as up to four columns. The lines were already over 120 columns
on screen; the tab was hiding it. One of them,
module_ri/exx_abfs_ctor_orbs.cpp, moves from 60 to 59 and so drops just
below the tool's pass line. Wrapping those lines would mean editing code
in a commit that is otherwise whitespace-only, so it is left for a
follow-up.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Critsium-xy
Critsium-xy force-pushed the chore/code-quality-easy-fixes branch from 9b0627e to 2ab39e7 Compare September 30, 2026 01:35
@mohanchen
mohanchen merged commit cd89b6f into deepmodeling:develop Sep 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor Refactor ABACUS codes The Absolute Zero Reduce the "entropy" of the code to 0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants