[PATCH] D126097: [clang-tidy] Adds the NSDateFormatter checker to clang-tidy

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat May 21 07:29:40 PDT 2022


Eugene.Zelenko added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/objc/NsdateformatterCheck.cpp:12
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+# include <ctype.h>
+
----------------
`cctype`? See `modernize-deprecated-headers`.


================
Comment at: clang-tools-extra/clang-tidy/objc/NsdateformatterCheck.cpp:30
+    char ValidDatePatternChars[] = {'G', 'y', 'Y', 'u', 'U', 'r', 'Q', 'q', 'M', 'L', 'I', 'w', 'W', 'd', 'D', 'F', 'g', 'E', 'e', 'c', 'a', 'b', 'B', 'h', 'H', 'K', 'k', 'j', 'J', 'C', 'm', 's', 'S', 'A', 'z', 'Z', 'O', 'v', 'V', 'X', 'x'};
+    for (auto it = Pattern.begin(); it != Pattern.end(); it++) {
+        char PatternChar = *it;
----------------
Range loop? See `modernize-loop-convert`.


================
Comment at: clang-tools-extra/clang-tidy/objc/NsdateformatterCheck.h:29
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
----------------
Please add `isLanguageVersionSupported`.


================
Comment at: clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp:32
+    CheckFactories.registerCheck<NsdateformatterCheck>(
+        "objc-NSDateFormatter");
     CheckFactories.registerCheck<AvoidNSErrorInitCheck>(
----------------
I think all check names are lowercase.


================
Comment at: clang-tools-extra/clang-tidy/objc/ObjCTidyModule.cpp:36
     CheckFactories.registerCheck<AssertEquals>("objc-assert-equals");
 
     CheckFactories.registerCheck<DeallocInCategoryCheck>(
----------------
Excessive newline.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/objc-NSDateFormatter.rst:5
+====================
+When ``NSDateFormatter`` is used to convert an ``NSDate`` type to a ``String`` type, the user
+can specify a custom format string. Certain format specifiers are undesirable
----------------
Please separate with newline.


================
Comment at: clang-tools-extra/docs/clang-tidy/checks/objc-NSDateFormatter.rst:10
+This checker reports as warnings the following string patterns in a date format specifier:
+1. yyyy + ww : Calendar year specified with week of a week year (unless YYYY is also specified).
+    Example 1:
----------------
Please enclose all examples and formats into single back-ticks.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D126097/new/

https://reviews.llvm.org/D126097



More information about the cfe-commits mailing list