Skip to content

[coap] reorder block-wise related methods for improved readability - #12228

Merged
jwhui merged 1 commit into
openthread:mainfrom
abtink:coap/blockwise-style-fixes
Dec 22, 2025
Merged

[coap] reorder block-wise related methods for improved readability#12228
jwhui merged 1 commit into
openthread:mainfrom
abtink:coap/blockwise-style-fixes

Conversation

@abtink

@abtink abtink commented Dec 19, 2025

Copy link
Copy Markdown
Member

This commit reorders block-wise related methods in both header and source files to group them within the same #if block. This is a purely stylistic change to improve code organization and readability and do not alter any functionality.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @abtink, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the maintainability and clarity of the CoAP module by significantly reorganizing its internal structure. It involves refactoring the response caching mechanism into an inner class and logically grouping block-wise transfer functionalities. These changes are purely stylistic, aiming to improve code readability and organization without introducing any functional modifications.

Highlights

  • Code Reorganization: The pull request primarily reorders block-wise related methods and other core CoAP functions within src/core/coap/coap.cpp and src/core/coap/coap.hpp to improve code organization and readability. This is a stylistic change and does not alter any functional behavior.
  • Response Cache Refactoring: The standalone ResponsesQueue class has been refactored and replaced by an inner class CoapBase::ResponseCache within src/core/coap/coap.hpp. Corresponding usage in src/core/coap/coap.cpp has been updated to use mResponseCache instead of mResponsesQueue.
  • Conditional Compilation Grouping: Block-wise transfer methods are now explicitly grouped under #if OPENTHREAD_CONFIG_COAP_BLOCKWISE_TRANSFER_ENABLE preprocessor directives, enhancing clarity regarding their conditional inclusion.
  • Stylistic Fall-through Updates: Minor stylistic changes were made in src/core/net/srp_client.cpp and src/ncp/ncp_base_ftd.cpp to replace // Fall through comments with the OT_FALL_THROUGH; macro for explicit fall-through indication.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@abtink
abtink force-pushed the coap/blockwise-style-fixes branch from 48ae75a to e1bebda Compare December 19, 2025 01:31

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces several valuable improvements to the CoAP implementation, focusing on code organization, readability, and maintainability. The block-wise transfer related methods have been reordered, which logically groups them and enhances readability. A significant and well-executed refactoring transforms the ResponsesQueue class into a private nested class CoapBase::ResponseCache, improving encapsulation and simplifying the responsibilities of the CoapBase class. Additionally, the replacement of // Fall through comments with the OT_FALL_THROUGH macro is a good stylistic improvement that leverages compiler checks for intentional fall-throughs. Overall, the changes are beneficial, correct, and improve the quality of the codebase.

@github-actions

github-actions Bot commented Dec 19, 2025

Copy link
Copy Markdown

Merging #12228 into main

name branch text data bss total
ot-cli-ftd f8d74d8 482256 860 66620 549736
50147d0 482256 860 66620 549736
+/- +0 +0 +0 +0
ot-ncp-ftd f8d74d8 447876 764 61856 510496
50147d0 447876 764 61856 510496
+/- +0 +0 +0 +0
ot-cli-mtd f8d74d8 373360 764 51052 425176
50147d0 373360 764 51052 425176
+/- +0 +0 +0 +0
ot-ncp-mtd f8d74d8 354308 764 46320 401392
50147d0 354308 764 46320 401392
+/- +0 +0 +0 +0
ot-cli-ftd-br f8d74d8 589584 868 136532 726984
50147d0 589584 868 136532 726984
+/- +0 +0 +0 +0
ot-rcp f8d74d8 63200 568 20804 84572
50147d0 63200 568 20804 84572
+/- +0 +0 +0 +0
Library files
name branch text data bss total
libopenthread-ftd.a f8d74d8 249286 95 40390 289771
50147d0 249286 95 40390 289771
+/- +0 +0 +0 +0
libopenthread-cli-ftd.a f8d74d8 61833 0 8091 69924
50147d0 61833 0 8091 69924
+/- +0 +0 +0 +0
libopenthread-ncp-ftd.a f8d74d8 33581 0 5948 39529
50147d0 33581 0 5948 39529
+/- +0 +0 +0 +0
libopenthread-mtd.a f8d74d8 166494 0 24854 191348
50147d0 166494 0 24854 191348
+/- +0 +0 +0 +0
libopenthread-cli-mtd.a f8d74d8 41426 0 8059 49485
50147d0 41426 0 8059 49485
+/- +0 +0 +0 +0
libopenthread-ncp-mtd.a f8d74d8 25805 0 5948 31753
50147d0 25805 0 5948 31753
+/- +0 +0 +0 +0
libopenthread-ftd-br.a f8d74d8 358274 100 110262 468636
50147d0 358274 100 110262 468636
+/- +0 +0 +0 +0
libopenthread-cli-ftd-br.a f8d74d8 80246 0 8131 88377
50147d0 80246 0 8131 88377
+/- +0 +0 +0 +0
libopenthread-rcp.a f8d74d8 9944 0 5060 15004
50147d0 9944 0 5060 15004
+/- +0 +0 +0 +0
libopenthread-radio.a f8d74d8 19479 0 238 19717
50147d0 19479 0 238 19717
+/- +0 +0 +0 +0

@codecov

codecov Bot commented Dec 19, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.18546% with 103 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.50%. Comparing base (f8d74d8) to head (2b87977).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/core/coap/coap.cpp 74.18% 103 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12228      +/-   ##
==========================================
- Coverage   76.46%   75.50%   -0.96%     
==========================================
  Files         681      678       -3     
  Lines       90870    95202    +4332     
==========================================
+ Hits        69485    71887    +2402     
- Misses      21385    23315    +1930     
Files with missing lines Coverage Δ
src/core/coap/coap.hpp 76.00% <ø> (-4.00%) ⬇️
src/core/coap/coap.cpp 79.47% <74.18%> (-3.21%) ⬇️

... and 279 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This commit reorders block-wise related methods in both header and
source files to group them within the same `#if` block. This is a
purely stylistic change to improve code organization and readability
and do not alter any functionality.
@abtink
abtink force-pushed the coap/blockwise-style-fixes branch from e1bebda to 2b87977 Compare December 19, 2025 19:40
@abtink
abtink marked this pull request as ready for review December 19, 2025 22:36
@jwhui
jwhui merged commit 1d25510 into openthread:main Dec 22, 2025
118 of 122 checks passed
@github-project-automation github-project-automation Bot moved this from Under review to Merged in Improving CoAP/TMF Jan 12, 2026
@github-project-automation github-project-automation Bot moved this to Under review in Improving CoAP/TMF Jan 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

3 participants