Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaces magic numbers with compile-time variables #159

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

mcakircali
Copy link
Contributor

example: seconds in a day would be eckit::Time::secondsInDay instead of 86400

@codecov-commenter
Copy link

codecov-commenter commented Jan 31, 2025

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Project coverage is 64.06%. Comparing base (ba59e08) to head (9425927).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
src/eckit/log/RotationTarget.cc 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #159      +/-   ##
===========================================
- Coverage    64.06%   64.06%   -0.01%     
===========================================
  Files         1079     1079              
  Lines        55673    55679       +6     
  Branches      4116     4118       +2     
===========================================
+ Hits         35665    35668       +3     
- Misses       20008    20011       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -31,6 +31,12 @@ using Second = double;

class Time {

public: // types
static constexpr Second secondsInMinute = 60;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure that the type Second is right here. IIRC that is a double - and the count of seconds in * is always integral - and is likely to be used in many integral expressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used Second here because DateTime and Time use Second (aka double)

e.g., age calculation cases are Second, while STL uses count time_t (aka long)

so, Second seemed more sensible to me, and no strong opinions.

happy to change if you suggest another type.

Copy link
Member

Choose a reason for hiding this comment

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

DateTime and Time use floating points to represent sub-second values.
time_t usually expresses the number of seconds since epoch.
For these constants (positive numbers expressing the relationship between time units, thus a-dimensional), I would prefer an integer value such as an unsigned long

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense. there's useconds_t (aka unsigned int), not unsigned long ..

any rejection to std::uint64_t or to template it secondsInMinute<double/uint64_t>?

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13069294755.

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci-hpc
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13069574140.

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci-hpc
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13070893697.

constexpr secondsInMinute
Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci-hpc
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13072520220.

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13072936241.

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13075144704.

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci-hpc
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13075242941.

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13075585738.

Copy link

Private downstream CI failed.
Workflow name: private-downstream-ci-hpc
View the logs at https://github.com/ecmwf-actions/private-downstream-ci/actions/runs/13075679612.

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.

4 participants