Fix function arguments names different warnings #3519
Merged
+16
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
This pull request addresses CppCheck's
Function Arguments Names Differentwarnings. Additional information on this topic was provided in the discussion section here.Here is the list of warnings:
While fixing the warnings, I ended up making more changes than I initially anticipated. Therefore, to make it easier for you to review and understand, I created a separate commit for each warning and will summarize my actions. After the review, I can squash them into a single commit.
Looking at the commits in the branch from the end to the beginning;
helpers-inl.h - load_levels -> ‘txt’ -> ‘input’
Although there are many different names used for the
load_levelsfunction and its parameter, such astxt,input, andlevels_string, it serves multiple purposes. Its primary purpose is to parse a string in the formatoff,logger1=debug,logger2=infoand set the log levels.To resolve the naming confusion here, I updated the name to
levels_spec. It is a specification that defines how levels are configured. This term is commonly used in technical literature for format strings and DSL-like structures.This does not affect API compatibility.
async_logger-inl.h - backend_sink_it_ -> ‘incoming_log_msg’ -> 'msg'
There is a deliberate semantic distinction between the frontend (
sink_it_) and backend (backend_sink_it_) functions in theasync_loggerclass. In the frontend, the message is processed in the context of the thread that called it immediately, while in the backend, the message has been queued, is time-delayed, and has changed ownership. Please correct me if I'm misunderstanding the design intent.While the name
incoming_log_msgwas used in the declaration to reflect this distinction, the definition simply usedmsg. The definition was corrected toincoming_log_msgto match the declaration. This both resolved the warning and preserved the semantic distinction in the design.Does not affect API compatibility.
spdlog-inl.h - should_log -> ‘lvl’ -> 'log_level'
lvlwas used in the declaration, whilelog_levelwas used in the definition. Since theset_levelandflush_onfunctions in the same file pair (spdlog.h/spdlog-inl.h) also use thelog_levelparameter, the declaration was updated tolog_levelfor consistency.This does not affect API compatibility.
Unimplemented Change:
log_msg-inl.h - log_msg -> ‘logger_name’ - 'a_logger_name'
In this case, the easy solution would be to change the content of the
logger_nameparameter in the second constructor function toa_logger_name. However, this would create a significant inconsistency by affecting the readability and understanding of the header file. The question is likely to arise: why is there noa_prefix in the other parameters?I believe the most appropriate approach is to add the
m_(member) prefix to thelog_msgstruct member variables and adjust the signatures accordingly. However, this would require modifying all member variables in their accessible areas (which would be quite extensive!). Therefore, I decided not to intervene on this point as it would also affect API compatibility.Perhaps we can address this in the future or in a separate PR if you wish, and I can assist you. FYI @tt4g
I may always have mistakes and omissions, so just leave a comment. I will look into it when I have time.
Best regards.