Skip to content
This repository has been archived by the owner on Jun 10, 2021. It is now read-only.

Fix linting issues #54

Merged
merged 3 commits into from
Jan 13, 2020
Merged

Fix linting issues #54

merged 3 commits into from
Jan 13, 2020

Conversation

mm318
Copy link
Member

@mm318 mm318 commented Dec 21, 2019

Fix linting issues found by clang-tidy 6.0.

@codecov
Copy link

codecov bot commented Dec 21, 2019

Codecov Report

Merging #54 into master will increase coverage by 0.81%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   40.95%   41.77%   +0.81%     
==========================================
  Files          28       28              
  Lines         967      881      -86     
  Branches      566      505      -61     
==========================================
- Hits          396      368      -28     
+ Misses         54       53       -1     
+ Partials      517      460      -57
Flag Coverage Δ
#unittests 41.77% <33.33%> (+0.81%) ⬆️
Impacted Files Coverage Δ
...ollector/linux_process_memory_measurement_node.cpp 31.81% <0%> (-1.52%) ⬇️
...llector/src/system_metrics_collector/utilities.cpp 35.21% <100%> (-5.01%) ⬇️
...r/test/system_metrics_collector/test_utilities.cpp 14.89% <0%> (-5.76%) ⬇️
...m_metrics_collector/linux_cpu_measurement_node.cpp 34.61% <0%> (ø) ⬆️
...src/system_metrics_collector/proc_pid_cpu_data.cpp
...r/test/system_metrics_collector/test_utilities.hpp 25% <0%> (ø)
...m_metrics_collector/test_linux_cpu_measurement.cpp 28.8% <0%> (+3.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9a51d68...d4fac45. Read the comment docs.

@@ -29,7 +29,7 @@ namespace system_metrics_collector
PeriodicMeasurementNode::PeriodicMeasurementNode(
const std::string & name,
const std::chrono::milliseconds measurement_period,
const std::string & publishing_topic,
const std::string & publishing_topic, // NOLINT
Copy link
Member

Choose a reason for hiding this comment

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

Can't we fix this? Generally, each NOLINT must contain a justification of why the linting rules has been disabled.

Copy link
Member Author

Choose a reason for hiding this comment

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

The issue the linter caught here was https://clang.llvm.org/extra/clang-tidy/checks/modernize-pass-by-value.html

I am not sure it warrants an API change. Any thoughts, @zmichaels11, @dabonnie, @emersonknapp?

I tried providing a justification with // NOLINT(modernize-pass-by-value), which clang-tidy is happy about but cpplint is not (it complained about unrecognized NOLINT criteria).

Choose a reason for hiding this comment

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

Can you add another comment explaining the // NOLINT

modernize-pass-by-value is also something we should probably look more into as a team.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am thinking we disregard modernize-pass-by-value (turn off modernize-pass-by-value checks) until we look more into it as a team, so NOLINT will not be applicable here for now.

@thomas-moulard
Copy link
Member

Note: this should be merged to master directly.

Copy link
Member

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

I'll be OOO until 08/01. I think Emerson, Davin and Aaron can give you good advice regarding clang-tidy.

@@ -35,7 +35,7 @@ constexpr const char kMemAvailable[] = "MemAvailable:";
constexpr const char kEmptyFile[] = "";
constexpr const int kInvalidMemorySample = -1;

double ComputeCpuTotalTime(const ProcCpuData measurement1, const ProcCpuData measurement2)
double ComputeCpuTotalTime(const ProcCpuData & measurement1, const ProcCpuData & measurement2)
Copy link
Member

Choose a reason for hiding this comment

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

@dabonnie I think this is done on purpose because those are lightweight objects, no?

Copy link

@zmichaels11 zmichaels11 Dec 23, 2019

Choose a reason for hiding this comment

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

I believe I made a comment on this last time suggesting pass by val because ProcCpuData has a size of 2 words. I'll re-check

Edit:
ProcCpuData now holds an std::string, so it should be passed by const ref.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think there was some confusing about ProcCpuData and ProcPidCpuData.

@mm318 mm318 force-pushed the miaofei/clang-tidy-linting branch 2 times, most recently from a9c6e83 to 321b1f9 Compare December 23, 2019 19:58
@mm318 mm318 changed the base branch from miaofei/style-guide to master December 23, 2019 19:59
Copy link
Member

@thomas-moulard thomas-moulard left a comment

Choose a reason for hiding this comment

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

This LGTM, let's make sure with @dabonnie that we can safely modify computeCpuTotalTime

Copy link
Contributor

@dabonnie dabonnie left a comment

Choose a reason for hiding this comment

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

Only nit to update the linux_process_memory_measurement_node.cpp with a comment of why struct is needed (so it doesn't keep coming up in review).

@mm318 mm318 force-pushed the miaofei/clang-tidy-linting branch from 321b1f9 to d4fac45 Compare January 9, 2020 23:25
@mm318
Copy link
Member Author

mm318 commented Jan 9, 2020

Rebased and added some changes to unit test source codes that were somehow missed earlier.

Copy link
Contributor

@piraka9011 piraka9011 left a comment

Choose a reason for hiding this comment

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

Don't see any issues with proposed changes so LGTM

@@ -57,7 +57,7 @@ class TestLinuxCpuMeasurementNode : public system_metrics_collector::LinuxCpuMea
const std::chrono::milliseconds publish_period)
: LinuxCpuMeasurementNode(name, measurement_period, publishing_topic, publish_period) {}

virtual ~TestLinuxCpuMeasurementNode() = default;
~TestLinuxCpuMeasurementNode() override = default;
Copy link
Member Author

Choose a reason for hiding this comment

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

This stylistic choice of clang-tidy's (declaring destructors as override) is a controversial one: isocpp/CppCoreGuidelines#721.

Copy link
Member Author

@mm318 mm318 Jan 11, 2020

Choose a reason for hiding this comment

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

Though I think the majority in the discussion sided with using override as being practically good, even if the behavior/semantics of a virtual destructor isn't quite the same as that of a virtual function.

@prajakta-gokhale
Copy link
Member

CodeCov Action is failing for unrelated reason - fix is tracked in https://github.com/ros-security/aws-oncall/issues/48.

@prajakta-gokhale prajakta-gokhale merged commit c581bfe into master Jan 13, 2020
@prajakta-gokhale prajakta-gokhale deleted the miaofei/clang-tidy-linting branch January 13, 2020 19:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants