From 663a9b0fb022864ed89f247e25465132a4eca589 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Tue, 14 Mar 2023 16:29:37 -0500 Subject: [PATCH] Add codespell as a linter (#1231) Following the example of https://github.com/rapidsai/cudf/pull/12097, this PR adds [codespell](https://github.com/codespell-project/codespell) as a linter for rmm. Note: I have not included a section in the CONTRIBUTING.md about how to use this (as was done in cudf's PR) because I plan to overhaul the contributing guides for all RAPIDS repos in the near term, and have a single source in docs.rapids.ai with common information about linters used in RAPIDS. Authors: - Bradley Dice (https://github.com/bdice) Approvers: - Rong Ou (https://github.com/rongou) - Ben Frederickson (https://github.com/benfred) - Mark Harris (https://github.com/harrism) URL: https://github.com/rapidsai/rmm/pull/1231 --- .pre-commit-config.yaml | 9 +++++++++ benchmarks/synchronization/synchronization.hpp | 2 +- include/rmm/detail/stack_trace.hpp | 2 +- .../mr/device/detail/stream_ordered_memory_resource.hpp | 2 +- pyproject.toml | 9 +++++++++ tests/device_buffer_tests.cu | 2 +- tests/device_scalar_tests.cpp | 2 +- 7 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 pyproject.toml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 261c57b27..bcbf17018 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -49,6 +49,15 @@ repos: (?x)^( ^benchmarks/utilities/cxxopts.hpp ) + - repo: https://github.com/codespell-project/codespell + rev: v2.2.4 + hooks: + - id: codespell + exclude: | + (?x)^( + pyproject.toml| + benchmarks/utilities/cxxopts.hpp + ) - repo: local hooks: - id: cmake-format diff --git a/benchmarks/synchronization/synchronization.hpp b/benchmarks/synchronization/synchronization.hpp index b0007d9b2..e9a3cd34a 100644 --- a/benchmarks/synchronization/synchronization.hpp +++ b/benchmarks/synchronization/synchronization.hpp @@ -50,7 +50,7 @@ } // Register the function as a benchmark. You will need to set the `UseManualTime()` - // flag in order to use the timer embeded in this class. + // flag in order to use the timer embedded in this class. BENCHMARK(sample_cuda_benchmark)->UseManualTime(); diff --git a/include/rmm/detail/stack_trace.hpp b/include/rmm/detail/stack_trace.hpp index 082cef02e..f658fe7ad 100644 --- a/include/rmm/detail/stack_trace.hpp +++ b/include/rmm/detail/stack_trace.hpp @@ -39,7 +39,7 @@ namespace rmm::detail { /** - * @brief stack_trace is a class that will capture a stack on instatiation for output later. + * @brief stack_trace is a class that will capture a stack on instantiation for output later. * It can then be used in an output stream to display stack information. * * rmm::detail::stack_trace saved_stack; diff --git a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp index fa53e480a..ddd3cb728 100644 --- a/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp +++ b/include/rmm/mr/device/detail/stream_ordered_memory_resource.hpp @@ -58,7 +58,7 @@ struct crtp { * This base class uses CRTP (https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern) * to provide static polymorphism to enable defining suballocator resources that maintain separate * pools per stream. All of the stream-ordering logic is contained in this class, but the logic - * to determine how memory pools are managed and the type of allocation is implented in a derived + * to determine how memory pools are managed and the type of allocation is implemented in a derived * class and in a free list class. * * For example, a coalescing pool memory resource uses a coalescing_free_list and maintains data diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..8a412773e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[tool.codespell] +# note: pre-commit passes explicit lists of files here, which this skip file list doesn't override - +# this is only to allow you to run codespell interactively +skip = "./pyproject.toml,./.git,./.github,./cpp/build,.*egg-info.*,./.mypy_cache,./benchmarks/utilities/cxxopts.hpp" +# ignore short words, and typename parameters like OffsetT +ignore-regex = "\\b(.{1,4}|[A-Z]\\w*T)\\b" +ignore-words-list = "inout" +builtin = "clear" +quiet-level = 3 diff --git a/tests/device_buffer_tests.cu b/tests/device_buffer_tests.cu index fadae7bb2..d4c34385e 100644 --- a/tests/device_buffer_tests.cu +++ b/tests/device_buffer_tests.cu @@ -438,7 +438,7 @@ TYPED_TEST(DeviceBufferTest, ResizeSmaller) buff.shrink_to_fit(rmm::cuda_stream_default); EXPECT_NE(nullptr, buff.data()); - // A reallocation should have occured + // A reallocation should have occurred EXPECT_NE(old_data, buff.data()); EXPECT_EQ(new_size, buff.size()); EXPECT_EQ(buff.capacity(), buff.size()); diff --git a/tests/device_scalar_tests.cpp b/tests/device_scalar_tests.cpp index fd92f7d6e..7fbdaec29 100644 --- a/tests/device_scalar_tests.cpp +++ b/tests/device_scalar_tests.cpp @@ -71,7 +71,7 @@ using Types = ::testing::Types scalar{this->stream, this->mr}; EXPECT_NE(nullptr, scalar.data());