Skip to content

refactor(lint): Enable linting for clp_s/Schema.hpp and clp_s/ColumnWriter.hpp; Remove unused ID field from BaseColumnWriter.#2042

Open
davidlion wants to merge 9 commits intoy-scope:mainfrom
davidlion:lint-stuff0
Open

refactor(lint): Enable linting for clp_s/Schema.hpp and clp_s/ColumnWriter.hpp; Remove unused ID field from BaseColumnWriter.#2042
davidlion wants to merge 9 commits intoy-scope:mainfrom
davidlion:lint-stuff0

Conversation

@davidlion
Copy link
Member

@davidlion davidlion commented Feb 26, 2026

Description

As the title says. These changes have no functional impact.

Part of the changes are to add in class organization comments that have been loosely applied up to this point in the code base. These comments are standardized in our guideline by y-scope/yscope-docs#53.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

CI passing.

Summary by CodeRabbit

  • Refactor

    • Simplified and standardized column writer interfaces for more consistent, safer behavior when creating and writing columns.
    • Unified schema indexing to a single Id type and modernized public APIs, adding stable iterator/view access and improved copy/move semantics.
  • Chores

    • Updated lint configuration to exclude a couple of internal headers from static analysis.

@davidlion davidlion requested review from a team and gibber9809 as code owners February 26, 2026 21:49
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8f92d3 and 9d82e3b.

📒 Files selected for processing (2)
  • components/core/src/clp_s/ColumnWriter.hpp
  • components/core/src/clp_s/Schema.hpp

Walkthrough

Removed per-column id storage and id-based constructors from column writers, updated writer constructors to accept shared dictionary/log contexts or be no-arg, refactored virtual signatures to trailing-return style; introduced Schema::id_t and converted Schema APIs/storage to use it with iterators; excluded two headers from lint checks.

Changes

Cohort / File(s) Summary
Column writer refactor
components/core/src/clp_s/ArchiveWriter.cpp, components/core/src/clp_s/ColumnWriter.hpp
Removed per-column id member/constructors; updated many column writer constructors to no-arg or to accept std::shared_ptr dictionaries/loggers; replaced virtual method signatures with trailing-return style; added/defaulted copy/move/assign on base writer.
Schema API/type updates
components/core/src/clp_s/Schema.hpp
Added using id_t = int32_t; replaced int32_t usages with id_t across API and internal storage; converted many methods to trailing-return syntax and [[nodiscard]]; m_schema now std::vector<id_t>; added iterator accessors.
Lint config change
taskfiles/lint.yaml
Removed clp_s/ColumnWriter.hpp and clp_s/Schema.hpp from the cpp lint/static-analysis file list.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the primary changes: enabling linting for two header files and removing an unused ID field from BaseColumnWriter, which aligns with the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 87.10% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@davidlion davidlion changed the title Enable linting for clp_s/Schema.hpp and clp_s/ColumnWriter.hpp; Remove unused ID field from BaseColumnWriter. refactor(lint): Enable linting for clp_s/Schema.hpp and clp_s/ColumnWriter.hpp; Remove unused ID field from BaseColumnWriter. Feb 26, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/core/src/clp_s/Schema.hpp`:
- Around line 125-129: The bounds check in Schema::get_view is overflow-prone
because i + size can wrap; replace it with a safe check such as ensuring size <=
m_schema.size() and i <= m_schema.size() - size (or equivalently i <=
m_schema.size() && size <= m_schema.size() - i) and throw OperationFailed when
the check fails; also construct the span with an explicit template parameter
(use std::span<Id>{m_schema}.subspan(i, size)) to match the style on line 117
and ensure type consistency with subspan.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad6e7b5 and f6255e9.

📒 Files selected for processing (4)
  • components/core/src/clp_s/ArchiveWriter.cpp
  • components/core/src/clp_s/ColumnWriter.hpp
  • components/core/src/clp_s/Schema.hpp
  • taskfiles/lint.yaml
💤 Files with no reviewable changes (1)
  • taskfiles/lint.yaml

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/core/src/clp_s/ColumnWriter.hpp`:
- Around line 205-207: The single-argument constructor
VariableStringColumnWriter(std::shared_ptr<VariableDictionaryWriter> var_dict)
should be marked explicit to prevent unintended implicit conversions; update the
VariableStringColumnWriter constructor declaration/definition to add the
explicit specifier (matching the change made for DictionaryFloatColumnWriter) so
the constructor reads as an explicit single-argument constructor.
- Around line 112-114: The single-argument constructor
DictionaryFloatColumnWriter(std::shared_ptr<VariableDictionaryWriter> var_dict)
should be marked explicit to prevent unintended implicit conversions; update the
constructor declaration/definition for DictionaryFloatColumnWriter to add the
explicit keyword (keeping the same parameter and move semantics for m_var_dict)
so the class no longer allows implicit conversions from
std::shared_ptr<VariableDictionaryWriter>.

In `@components/core/src/clp_s/Schema.hpp`:
- Around line 125-130: The bounds check in get_view is inverted and can
underflow; change the guard so it throws when the requested range is invalid by
checking that size is not greater than m_schema.size() and that i + size does
not exceed m_schema.size() (e.g. use a safe check like "if (size >
m_schema.size() || i > m_schema.size() - size) throw
OperationFailed(ErrorCodeOutOfBounds, ...)" or equivalently "if (i + size >
m_schema.size())" using a safe pre-check), keeping the throw of
OperationFailed(ErrorCodeOutOfBounds, __FILENAME__, __LINE__) and then return
the subspan from m_schema as before.

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6255e9 and 1241f08.

📒 Files selected for processing (2)
  • components/core/src/clp_s/ColumnWriter.hpp
  • components/core/src/clp_s/Schema.hpp

@davidlion davidlion marked this pull request as draft February 27, 2026 15:20
@davidlion davidlion marked this pull request as ready for review February 28, 2026 15:30
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/core/src/clp_s/Schema.hpp`:
- Around line 66-67: Ensure m_num_ordered cannot exceed the schema size before
creating the ordered view: validate and clamp or reject the value set by
set_num_ordered(size_t) (or perform the check right before creating the ordered
span in the code that uses m_num_ordered), comparing m_num_ordered against
m_schema.size(); if it is larger, either reduce it to m_schema.size() or
return/throw an error so the span creation that uses m_num_ordered cannot go out
of bounds (references: set_num_ordered, m_num_ordered, m_schema, and the
ordered-span creation code that reads m_num_ordered).

ℹ️ Review info

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1241f08 and b8f92d3.

📒 Files selected for processing (2)
  • components/core/src/clp_s/ColumnWriter.hpp
  • components/core/src/clp_s/Schema.hpp

Comment on lines +66 to 67
auto set_num_ordered(size_t num_ordered) -> void { m_num_ordered = num_ordered; }

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Validate ordered-length before creating the ordered view.

Line 66 allows any m_num_ordered, but Line 117 uses it directly as span length. If it exceeds m_schema.size(), downstream access can go out of bounds.

Suggested fix
-    [[nodiscard]] auto get_ordered_schema_view() -> std::span<Id> {
-        return std::span<Id>{m_schema.data(), m_num_ordered};
-    }
+    [[nodiscard]] auto get_ordered_schema_view() -> std::span<Id> {
+        if (m_num_ordered > m_schema.size()) {
+            throw OperationFailed(ErrorCodeOutOfBounds, __FILENAME__, __LINE__);
+        }
+        return std::span<Id>{m_schema.data(), m_num_ordered};
+    }

Also applies to: 116-118

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/core/src/clp_s/Schema.hpp` around lines 66 - 67, Ensure
m_num_ordered cannot exceed the schema size before creating the ordered view:
validate and clamp or reject the value set by set_num_ordered(size_t) (or
perform the check right before creating the ordered span in the code that uses
m_num_ordered), comparing m_num_ordered against m_schema.size(); if it is
larger, either reduce it to m_schema.size() or return/throw an error so the span
creation that uses m_num_ordered cannot go out of bounds (references:
set_num_ordered, m_num_ordered, m_schema, and the ordered-span creation code
that reads m_num_ordered).

@junhaoliao junhaoliao added this to the March 2026 milestone Mar 7, 2026
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.

2 participants