Merge topic 'ci-typos'

c3777c1536 ci: Extend spellcheck job with 'typos' tool
d11552c2d9 codespell: Exclude paths by patterns following pre-commit check conventions
11d0a631d4 codespell: Split multi-valued configuration across multiple lines
54dfadaf5a ci: Rename "codespell" job to more general name "spellcheck"
17fc94e5e3 ci: Add typos 1.29.4 to Fedora base image
ddf8220572 ci: Use Fedora 41 default flang package now that it is new enough
1e2d19ea4f gitignore: Tell tools honoring .gitignore to ignore .git too
0d0a94bcfb Tests: Fix Fortran syntax for initialized variable

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !10211
This commit is contained in:
Brad King 2025-01-23 14:33:24 +00:00 committed by Kitware Robot
commit 63924c4afa
29 changed files with 231 additions and 21 deletions

View File

@ -4,5 +4,58 @@ check-hidden =
# Disable warnings about binary files
quiet-level = 2
builtin = clear,rare,en-GB_to_en-US
skip = */.git,*/build,*/Copyright.txt,*/CTestCustom.cmake.in,*/doxygen.config,*/Modules/Internal/CPack/NSIS.template.in,*/Source/CursesDialog/form/*,*/Source/kwsys/*,*/Tests/RunCMake/CPack/tests/DMG_SLA/German.*,*/Tests/RunCMake/ParseImplicitData/*.input,*/Tests/StringFileTest/test.utf8,*.pfx,*/Utilities/cm*
ignore-words-list = aci,ags,ake,ans,ba,ccompiler,cconfiguration,certi,conly,copyin,dependees,dne,dum,earch,ect,filetest,fo,helpfull,hiden,isnt,keypair,nd,ned,nin,nknown,ot,pard,sectionin,seh,ser,te,upto,varn,vas,wee
# Skip paths matching fnmatch glob patterns.
skip =
.git,
.typos.toml,
build,
Copyright.txt,
CTestCustom.cmake.in,
Modules/Internal/CPack/NSIS.template.in,
Source/CursesDialog/form/*,
Source/kwsys/*,
Tests/RunCMake/CPack/tests/DMG_SLA/German.*,
Tests/RunCMake/ParseImplicitData/*.input,
Tests/StringFileTest/test.utf8,
Utilities/cm*,
*.pfx,
# noqa: spellcheck off
ignore-words-list =
aci,
ags,
ake,
ans,
ba,
ccompiler,
cconfiguration,
certi,
conly,
copyin,
dependees,
dne,
dum,
earch,
ect,
filetest,
fo,
helpfull,
hiden,
isnt,
keypair,
nd,
ned,
nin,
nknown,
ot,
pard,
sectionin,
seh,
ser,
te,
upto,
varn,
vas,
wee,
# noqa: spellcheck on

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
# Help tools that honor '.gitignore' (redundant for Git itself).
/.git
/CMakeUserPresets.json
# Common build directories

View File

@ -95,9 +95,9 @@ u:cmake.org-help:
# Lint builds
l:codespell:
l:spellcheck:
extends:
- .cmake_codespell_linux
- .cmake_spellcheck_linux
- .linux_x86_64_tags
- .run_automatically

21
.gitlab/ci/codespell.bash Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
set -e
result=0
# 'codespell' with no arguments adds a leading './' to all paths.
# Avoid that by globbing top-level entries explicitly.
shopt -s dotglob
echo "Running 'codespell' on source code..."
codespell * || result=1
shopt -u dotglob
if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
for COMMIT in $(git rev-list "^$CI_MERGE_REQUEST_DIFF_BASE_SHA" "$CI_COMMIT_SHA"); do
echo "Running 'codespell' on commit message of $COMMIT..."
git show --format=%B -s "$COMMIT" | codespell - || result=1
done
fi
exit $result

View File

@ -6,6 +6,7 @@ FROM ${BASE_IMAGE} AS dnf-cache
# Populate DNF cache w/ the fresh metadata and prefetch packages.
RUN --mount=type=bind,source=deps_packages.lst,target=/root/deps_packages.lst \
--mount=type=bind,source=iwyu_packages.lst,target=/root/iwyu_packages.lst \
--mount=type=bind,source=rust_packages.lst,target=/root/rust_packages.lst \
--mount=type=bind,source=rvm_packages.lst,target=/root/rvm_packages.lst \
--mount=type=tmpfs,target=/var/log \
--mount=type=tmpfs,target=/tmp \
@ -18,6 +19,16 @@ RUN --mount=type=bind,source=deps_packages.lst,target=/root/deps_packages.lst \
$(grep -h '^[^#]\+$' /root/*.lst)
FROM ${BASE_IMAGE} AS rust-build
LABEL maintainer="Ben Boeckel <ben.boeckel@kitware.com>"
RUN --mount=type=bind,source=install_rust.sh,target=/root/install_rust.sh \
--mount=type=bind,source=rust_packages.lst,target=/root/rust_packages.lst \
--mount=type=cache,from=dnf-cache,source=/var/lib/dnf,target=/var/lib/dnf,sharing=private \
--mount=type=tmpfs,target=/var/log \
--mount=type=tmpfs,target=/tmp \
sh /root/install_rust.sh
FROM ${BASE_IMAGE} AS rvm-build
LABEL maintainer="Ben Boeckel <ben.boeckel@kitware.com>"
@ -51,6 +62,9 @@ RUN --mount=type=bind,source=install_deps.sh,target=/root/install_deps.sh \
--mount=type=tmpfs,target=/tmp \
sh /root/install_deps.sh
RUN --mount=type=bind,from=rust-build,source=/root,target=/root \
tar -C /usr/local -xf /root/rust.tar
RUN --mount=type=bind,from=rvm-build,source=/root,target=/root \
tar -C /usr/local -xf /root/rvm.tar

View File

@ -10,7 +10,7 @@ clang-devel
clang-tools-extra
clang-tools-extra-devel
compiler-rt
flang-19.1.0-2.fc41
flang
gcc-c++
git-core
lfortran

View File

@ -0,0 +1,15 @@
#!/bin/sh
set -e
dnf install \
--setopt=install_weak_deps=False \
--setopt=fastestmirror=True \
--setopt=max_parallel_downloads=10 \
-y \
$(grep '^[^#]\+$' /root/rust_packages.lst)
typos_version=1.29.4
cargo install --root /usr/local --version "$typos_version" typos-cli
tar -C /usr/local -cf /root/rust.tar bin/typos

View File

@ -0,0 +1 @@
rust-cargo-devel

View File

@ -3,13 +3,14 @@
set -e
result=0
echo "Running codespell on source code..."
codespell || result=1
echo "Running 'typos' on source code..."
typos || result=1
if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
for COMMIT in $(git rev-list "^$CI_MERGE_REQUEST_DIFF_BASE_SHA" "$CI_COMMIT_SHA"); do
echo "Running codespell on commit message of $COMMIT..."
git show --format=%B -s "$COMMIT" | codespell - || result=1
echo "Running 'typos' on commit message of $COMMIT..."
git show --format=%B -s "$COMMIT" | typos - || result=1
done
fi

View File

@ -65,7 +65,7 @@
### Fedora
.fedora41:
image: "kitware/cmake:ci-fedora41-x86_64-2024-11-11"
image: "kitware/cmake:ci-fedora41-x86_64-2025-01-21"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes"
@ -580,11 +580,12 @@
- .gitlab/ci/cmake_version_update.sh
interruptible: false # The job internally fetches and retries.
.cmake_codespell_linux:
.cmake_spellcheck_linux:
stage: build
extends: .fedora41
script:
- .gitlab/ci/codespell.sh
- .gitlab/ci/codespell.bash
- .gitlab/ci/typos.bash
interruptible: true
.cmake_build_linux:

67
.typos.toml Normal file
View File

@ -0,0 +1,67 @@
# The manual about all configuration options is here:
# https://github.com/crate-ci/typos/blob/master/docs/reference.md
[default]
check-file = true
check-filename = true
extend-ignore-re = [
# NOTE Allow to mark a block of text to exclude from spellchecking
"(?s)(#|/(/|\\*)|\\.\\.)\\s*(NOQA|noqa):? spellcheck(: *|=| +)off.*?\\n\\s*(#|/(/|\\*)|\\.\\.)\\s*(NOQA|noqa):? spellcheck(: *|=| +)on"
# NOTE Allow to mark a line to exclude from spellchecking
, "(?Rm)^.*(#|/(/|\\*)|\\.\\.)\\s*(NOQA|noqa):? spellcheck(: *|=| +)disable-line$"
]
locale = "en-us"
# Add repo-wide false positives here in the form of `word = "word"`.
# Check the manual for details.
[default.extend-words]
HPE = "HPE"
# British spelling of `XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER` property name.
BEHAVIOUR = "BEHAVIOUR"
# Misspelled `Fortran_BUILDING_INSTRINSIC_MODULES` property name kept for compatibility: `INSTRINSIC` should be `INTRINSIC`.
INSTRINSIC = "INSTRINSIC"
# This is a file extension for `cobertura-merge`
ser = "ser"
# The Ninja option name
restat = "restat"
# SpectreMitigation
Spectre = "Spectre"
[type.cmake.extend-identifiers]
COMMANDs = "COMMANDs"
xCOMMANDx = "xCOMMANDx"
[type.cmake.extend-words]
# Some compiler's options trigger false-positives
Fo = "Fo"
ot = "ot"
# Part of compiler executable name, e.g., `arm-unknown-nto-qnx6`, but also could be in a literal string.
nto = "nto"
[type.cpp.extend-identifiers]
APPENDed = "APPENDed"
[type.json.extend-identifiers]
# Some compiler options from `Templates/MSBuild/FlagTables/*.json` trigger too many false-positives.
Fo = "Fo"
fo = "fo"
Ot = "Ot"
SEH = "SEH"
[files]
ignore-hidden = false
ignore-dot = false
extend-exclude = [
"Copyright.txt"
# Exclude third-party sources.
, "Source/CursesDialog/form/"
, "Source/kwsys/"
, "Source/bindexplib.cxx"
, "Source/cmcldeps.cxx"
, "Source/QtDialog/*.ui"
, "Utilities/cm*"
, "Utilities/ClangTidyModule"
, "Utilities/KWIML"
# FIXME: Fix spelling typos in tests. Exclude for now.
, "Tests"
]

View File

@ -105,6 +105,8 @@ iteration variables as follows:
- if any of the lists are shorter, the corresponding iteration
variable is not defined for the current iteration.
.. noqa: spellcheck off
.. code-block:: cmake
list(APPEND English one two three four)
@ -129,6 +131,8 @@ yields::
-- en=three, ba=tiga
-- en=four, ba=
.. noqa: spellcheck on
See Also
^^^^^^^^

View File

@ -163,11 +163,15 @@ The following characters have special meaning in regular expressions:
:command:`if(MATCHES)`, save subgroup matches in the variables
:variable:`CMAKE_MATCH_<n>` for ``<n>`` 0..9.
.. noqa: spellcheck off
``*``, ``+`` and ``?`` have higher precedence than concatenation. ``|``
has lower precedence than concatenation. This means that the regular
expression ``^ab+d$`` matches ``abbd`` but not ``ababd``, and the regular
expression ``^(ab|cd)$`` matches ``ab`` but not ``abd``.
.. noqa: spellcheck on
CMake language :ref:`Escape Sequences` such as ``\t``, ``\r``, ``\n``,
and ``\\`` may be used to construct literal tabs, carriage returns,
newlines, and backslashes (respectively) to pass in a regex. For example:

View File

@ -3,6 +3,11 @@ VS_SHADER_OBJECT_FILE_NAME
.. versionadded:: 3.12
.. noqa: spellcheck off
.. Ignore `-Fo` here
Specifies a file name for the compiled shader object file for an ``.hlsl``
source file. This adds the ``-Fo`` flag to the command line for the FxCompiler
tool.
.. noqa: spellcheck on

View File

@ -19,14 +19,18 @@ macro (CHECK_COMPILER_FLAG_COMMON_PATTERNS _VAR)
FAIL_REGEX "invalid argument .*option" # Intel
FAIL_REGEX "ignoring option .*argument required" # Intel
FAIL_REGEX "ignoring option .*argument is of wrong type" # Intel
# noqa: spellcheck off
FAIL_REGEX "[Uu]nknown option" # HP
# noqa: spellcheck on
FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro
FAIL_REGEX "command option .* is not recognized" # XL
FAIL_REGEX "command option .* contains an incorrect subargument" # XL
FAIL_REGEX "Option .* is not recognized. Option will be ignored." # XL
FAIL_REGEX "not supported in this configuration. ignored" # AIX
FAIL_REGEX "File with unknown suffix passed to linker" # PGI
# noqa: spellcheck off
FAIL_REGEX "[Uu]nknown switch" # PGI
# noqa: spellcheck on
FAIL_REGEX "WARNING: unknown flag:" # Open64
FAIL_REGEX "Incorrect command line option:" # Borland
FAIL_REGEX "Warning: illegal option" # SunStudio 12

View File

@ -215,7 +215,7 @@ function(_ICU_FIND)
endif()
if(component STREQUAL "in")
list(APPEND component_libnames "icui18n")
list(APPEND component_debug_libnames "icui18nd")
list(APPEND component_debug_libnames "icui18nd") # noqa: spellcheck disable-line
endif()
if(static_prefix)

View File

@ -618,11 +618,13 @@ function (_MPI_interrogate_compiler LANG)
# At this point, we obtained some output from a compiler wrapper that works.
# We'll now try to parse it into variables with meaning to us.
if(LANG STREQUAL "Fortran")
# noqa: spellcheck off
# If MPICH (and derivates) didn't recognize the Fortran compiler include flag during configuration,
# they'll return a set of three commands, consisting out of a symlink command for mpif.h,
# the actual compiler command and deletion of the created symlink.
# Especially with M(VA)PICH-1, this appears to happen erroneously, and therefore we should translate
# this output into an additional include directory and then drop it from the output.
# noqa: spellcheck on
if(MPI_COMPILE_CMDLINE MATCHES "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h")
get_filename_component(MPI_INCLUDE_DIRS_WORK "${CMAKE_MATCH_1}" DIRECTORY)
string(REGEX REPLACE "^ln -s ([^\" ]+|\"[^\"]+\") mpif.h\n" "" MPI_COMPILE_CMDLINE "${MPI_COMPILE_CMDLINE}")
@ -955,6 +957,7 @@ function(_MPI_guess_settings LANG)
# Should a user be employing PGI or have built its own set and provided it via cache variables, the
# splitting routine would have located the module files.
# noqa: spellcheck off
# For C and C++, we're done here (MSMPI does not ship the MPI-2 C++ bindings) - however, for Fortran
# we need some extra library to glue Fortran support together:
# MSMPI ships 2-4 Fortran libraries, each for different Fortran compiler behaviors. The library names
@ -964,6 +967,7 @@ function(_MPI_guess_settings LANG)
# The second difference is the last but one letter, if it's an e(nd), the length of a string argument is
# passed by the Fortran compiler after all other arguments on the parameter list, if it's an m(ixed),
# it's passed immediately after the string address.
# noqa: spellcheck on
# To summarize:
# - msmpifec: CHARACTER length passed after the parameter list and using cdecl calling convention

View File

@ -42,6 +42,7 @@ endmacro()
set(RTI_DEFINITIONS "-DRTI_USES_STD_FSTREAM")
# noqa: spellcheck off
# Detect the CERTI installation, http://www.cert.fr/CERTI
# Detect the MAK Technologies RTI installation, http://www.mak.com/products/rti.php
# note: the following list is ordered to find the most recent version first
@ -55,6 +56,7 @@ set(RTI_POSSIBLE_DIRS
set(RTI_OLD_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
# The MAK RTI has the "lib" prefix even on Windows.
set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
# noqa: spellcheck on
find_library(RTI_LIBRARY
NAMES RTI RTI-NG

View File

@ -52,9 +52,11 @@ if(NOT CMake_VERSION_NO_GIT)
set(git_subject "${CMAKE_MATCH_2}")
# If this is not the exact commit of a release, add dev info.
# noqa: spellcheck off
if(NOT "${git_subject}" MATCHES "^[Cc][Mm]ake ${CMake_VERSION}$")
string(APPEND CMake_VERSION "-g${git_hash}")
endif()
# noqa: spellcheck on
# If this is a work tree, check whether it is dirty.
if(COMMAND _git)

View File

@ -128,7 +128,7 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
{
ControlWord("viewkind4");
ControlWord("uc1");
ControlWord("pard");
ControlWord("pard"); // noqa: spellcheck disable-line
ControlWord("f0");
ControlWord("fs14");
}

View File

@ -34,7 +34,7 @@
#include "cmXMLWriter.h"
static const char* cmCTestErrorMatches[] = {
"^[Bb]us [Ee]rror",
"^[Bb]us [Ee]rror", // noqa: spellcheck disable-line
"^[Ss]egmentation [Vv]iolation",
"^[Ss]egmentation [Ff]ault",
":.*[Pp]ermission [Dd]enied",

View File

@ -10,6 +10,7 @@
class cmCTest;
class cmCTestCoverageHandlerContainer;
// noqa: spellcheck off
/** \class cmParsePythonCoverage
* \brief Parse coverage.py Python coverage information
*
@ -19,6 +20,7 @@ class cmCTestCoverageHandlerContainer;
* Java-based Cobertura coverage application. This helper class parses
* that XML file to fill the coverage-handler container.
*/
// noqa: spellcheck on
class cmParseCoberturaCoverage
{
public:

View File

@ -626,7 +626,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
xml.StartElement("storageModule");
xml.Attribute("moduleId", "org.eclipse.cdt.core.settings");
xml.StartElement("cconfiguration");
xml.StartElement("cconfiguration"); // noqa: spellcheck disable-line
xml.Attribute("id", "org.eclipse.cdt.core.default.config.1");
// Configuration settings...
@ -1018,7 +1018,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
cmExtraEclipseCDT4Generator::AppendStorageScanners(xml, *mf);
// noqa: spellcheck off
xml.EndElement(); // cconfiguration
// noqa: spellcheck on
xml.EndElement(); // storageModule
xml.StartElement("storageModule");

View File

@ -35,7 +35,7 @@ bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
<< " " << lfc << "\n"
<< "closes on the line\n"
<< " " << closingContext << "\n"
<< "with mis-matching arguments.";
<< "with mis-matching arguments."; // noqa: spellcheck disable-line
/* clang-format on */
mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str());
} else if (!this->EndCommandSupportsArguments() &&

View File

@ -975,6 +975,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
cmXMLElement epg(eprj, "PropertyGroup");
epg.Attribute("Label", "Configuration");
{
// noqa: spellcheck off
cmXMLElement ect(epg, "ConfigurationType");
if (this->IsNsightTegra()) {
// Tegra-Android platform does not understand "Utility".
@ -982,6 +983,7 @@ bool cmGlobalVisualStudio10Generator::FindVCTargetsPath(cmMakefile* mf)
} else {
ect.Content("Utility");
}
// noqa: spellcheck on
}
cmXMLElement(epg, "CharacterSet").Content("MultiByte");
if (this->IsNsightTegra()) {

View File

@ -518,8 +518,9 @@ static cmVS7FlagTable cmVS8ExtraFlagTable[] = {
// Exception handling mode. If no entries match, it will be FALSE.
{ "ExceptionHandling", "GX", "enable c++ exceptions", "1", 0 },
{ "ExceptionHandling", "EHsc", "enable c++ exceptions", "1", 0 },
// noqa: spellcheck off
{ "ExceptionHandling", "EHa", "enable SEH exceptions", "2", 0 },
// noqa: spellcheck on
{ "EnablePREfast", "analyze", "", "true", 0 },
{ "EnablePREfast", "analyze-", "", "false", 0 },

View File

@ -389,7 +389,9 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = {
{ "FloatingPointModel", "fp:strict", "Use strict floating point model", "1",
0 },
{ "FloatingPointModel", "fp:fast", "Use fast floating point model", "2", 0 },
// noqa: spellcheck off
{ "FavorSizeOrSpeed", "Ot", "Favor fast code", "1", 0 },
// noqa: spellcheck on
{ "FavorSizeOrSpeed", "Os", "Favor small code", "2", 0 },
{ "CompileAs", "TC", "Compile as c code", "1", 0 },
{ "CompileAs", "TP", "Compile as c++ code", "2", 0 },

View File

@ -2033,7 +2033,7 @@ int cmcmd::RunLLVMRC(std::vector<std::string> const& args)
static const cmsys::RegularExpression llvm_rc_only_double_arg(
"^[-/](C|LN|L)(.)?");
static const cmsys::RegularExpression common_double_arg(
"^[-/](D|U|I|FO|fo|Fo)(.)?");
"^[-/](D|U|I|FO|fo|Fo)(.)?"); // noqa: spellcheck disable-line
bool acceptNextArg = false;
bool skipNextArg = false;
for (std::string const& arg : cmMakeRange(args).advance(4)) {
@ -2448,7 +2448,7 @@ int cmVSLink::LinkIncremental()
// Compile the resource file.
std::vector<std::string> rcCommand;
rcCommand.push_back(this->RcPath.empty() ? "rc" : this->RcPath);
rcCommand.emplace_back("/fo");
rcCommand.emplace_back("/fo"); // noqa: spellcheck disable-line
rcCommand.push_back(this->ManifestFileRes);
rcCommand.push_back(this->ManifestFileRC);
if (!RunCommand("RC Pass 1", rcCommand, this->Verbose, FORMAT_DECIMAL)) {

View File

@ -1,6 +1,6 @@
#define int INTEGER
! This single unmatched quote ' should not cause an error during compilation
PROGRAM PREPRO
int f = 1
int :: f = 1
PRINT*, f
END