google / styleguide

Style guides for Google-originated open-source projects
https://google.github.io/styleguide/
Apache License 2.0
37.53k stars 13.3k forks source link

Add rule for default gflag DEFINE #715

Closed bmatican closed 2 years ago

bmatican commented 2 years ago

Adding a rule to throw warnings on new code adding gflags via the original gflag API.

Validated all rules by making a simple change to the YB repo, adding all types of flags we support

diff --git a/src/yb/master/master_main.cc b/src/yb/master/master_main.cc
index 3d0a2a2..b59c993 100644
--- a/src/yb/master/master_main.cc
+++ b/src/yb/master/master_main.cc
@@ -74,6 +74,13 @@ DECLARE_bool(use_docdb_aware_bloom_filter);
 DECLARE_int32(follower_unavailable_considered_failed_sec);
 DECLARE_int32(log_min_seconds_to_retain);

+DEFINE_bool(bogdan_bool, 0, "testing");
+DEFINE_int32(bogdan_int32, 0, "testing");
+DEFINE_int64(bogdan_int64, 0, "testing");
+DEFINE_uint64(bogdan_uint64, 0, "testing");
+DEFINE_double(bogdan_double, 0, "testing");
+DEFINE_string(bogdan_string, "", "testing");
+
 using namespace std::literals;

 namespace yb {

Confirmed lint warnings for all of them as expected


>>> Lint for src/yb/master/master_main.cc:

   Error  (build/gflag_default_api) build/gflag_default_api
    Please use the new DEFINE_RUNTIME and DEFINE_NON_RUNTIME macros.

              74 DECLARE_int32(follower_unavailable_considered_failed_sec);
              75 DECLARE_int32(log_min_seconds_to_retain);
              76
    >>>       77 DEFINE_bool(bogdan_bool, 0, "testing");
              78 DEFINE_int32(bogdan_int32, 0, "testing");
              79 DEFINE_int64(bogdan_int64, 0, "testing");
              80 DEFINE_uint64(bogdan_uint64, 0, "testing");

   Error  (build/gflag_default_api) build/gflag_default_api
    Please use the new DEFINE_RUNTIME and DEFINE_NON_RUNTIME macros.

              75 DECLARE_int32(log_min_seconds_to_retain);
              76
              77 DEFINE_bool(bogdan_bool, 0, "testing");
    >>>       78 DEFINE_int32(bogdan_int32, 0, "testing");
              79 DEFINE_int64(bogdan_int64, 0, "testing");
              80 DEFINE_uint64(bogdan_uint64, 0, "testing");
              81 DEFINE_double(bogdan_double, 0, "testing");

   Error  (build/gflag_default_api) build/gflag_default_api
    Please use the new DEFINE_RUNTIME and DEFINE_NON_RUNTIME macros.

              76
              77 DEFINE_bool(bogdan_bool, 0, "testing");
              78 DEFINE_int32(bogdan_int32, 0, "testing");
    >>>       79 DEFINE_int64(bogdan_int64, 0, "testing");
              80 DEFINE_uint64(bogdan_uint64, 0, "testing");
              81 DEFINE_double(bogdan_double, 0, "testing");
              82 DEFINE_string(bogdan_string, "", "testing");

   Error  (build/gflag_default_api) build/gflag_default_api
    Please use the new DEFINE_RUNTIME and DEFINE_NON_RUNTIME macros.

              77 DEFINE_bool(bogdan_bool, 0, "testing");
              78 DEFINE_int32(bogdan_int32, 0, "testing");
              79 DEFINE_int64(bogdan_int64, 0, "testing");
    >>>       80 DEFINE_uint64(bogdan_uint64, 0, "testing");
              81 DEFINE_double(bogdan_double, 0, "testing");
              82 DEFINE_string(bogdan_string, "", "testing");
              83

   Error  (build/gflag_default_api) build/gflag_default_api
    Please use the new DEFINE_RUNTIME and DEFINE_NON_RUNTIME macros.

              78 DEFINE_int32(bogdan_int32, 0, "testing");
              79 DEFINE_int64(bogdan_int64, 0, "testing");
              80 DEFINE_uint64(bogdan_uint64, 0, "testing");
    >>>       81 DEFINE_double(bogdan_double, 0, "testing");
              82 DEFINE_string(bogdan_string, "", "testing");
              83
              84 using namespace std::literals;

   Error  (build/gflag_default_api) build/gflag_default_api
    Please use the new DEFINE_RUNTIME and DEFINE_NON_RUNTIME macros.

              79 DEFINE_int64(bogdan_int64, 0, "testing");
              80 DEFINE_uint64(bogdan_uint64, 0, "testing");
              81 DEFINE_double(bogdan_double, 0, "testing");
    >>>       82 DEFINE_string(bogdan_string, "", "testing");
              83
              84 using namespace std::literals;
              85
google-cla[bot] commented 2 years ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

bmatican commented 2 years ago

Oops, I'm sorry, I opened this against the wrong repo.