[PATCH] D23848: Add a clang-tidy Visual Studio extension

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 24 14:04:29 PDT 2016


alexfh added a comment.

In https://reviews.llvm.org/D23848#524608, @zturner wrote:

> I can fix the empty lines, but keep in mind that Visual Studio's C# editor is MUCH more aggressive about auto-formatting your code.  So it seems like a fruitless endeavor to me, as we will constantly be fighting against their auto formatter, which does this automatically every time you add a new function.


I would definitely not fight with visual editors that reset formatting every time you touch the file. However, if VS only adds empty lines when initially adding a function, that doesn't promise much resistance ;)


================
Comment at: CMakeLists.txt:6
@@ -5,2 +5,3 @@
 add_subdirectory(clang-tidy)
+add_subdirectory(clang-tidy-vs)
 endif()
----------------
zturner wrote:
> alexfh wrote:
> > Should the plugin be placed inside clang-tidy directory?
> I followed the same way that the clang format VS extension uses.  I don't mind to move it, I just did it this way for consistency.
I don't feel strongly either way. Let's figure this out later.

================
Comment at: clang-tidy-vs/ClangTidy/ClangTidy.vsct:22
@@ +21,3 @@
+  <Extern href="vsshlids.h"/>
+
+
----------------
Eugene.Zelenko wrote:
> Unnecessary empty line, same below in many places here.
If there's a way to visually edit this file, I wouldn't care about formatting.

================
Comment at: clang-tidy-vs/ClangTidy/ClangTidyProperties.cs:81
@@ +80,3 @@
+        [ClangTidyCheck("cert-dcl50-cpp")]
+        public bool CERTDCL50
+        {
----------------
zturner wrote:
> alexfh wrote:
> > I hope, this file is generated?
> > 
> > A way to update this file should be documented.
> No, I actually typed this entire file :-/  I don't know of a good way to auto generate it.  We would need a single file, perhaps Yaml or something, consisting of:
> 
> 1. Category Name
> 2. Display Name
> 3. Description
> 4. clang-tidy built in default value of check.
> 
> At that point, we wouldn't even need to generate the file, we could read it at runtime and add the properties dynamically (through the `ICustomTypeDescriptor` interface).
> 
> For now though, the way to update the file is to copy / paste one property and change the values accordingly to add a new check.
Manually updating this file won't fly =[

I guess, we could try to use .rst files as the source of truth. They follow a strict naming scheme (<check-name>.rst) and we could require the first paragraph of the text to be a single-sentence description of the check suitable for this purpose as well.

I'd also make the display name the same as the full clang-tidy check name (`DCL50-CPP` is neither more useful nor convenient than the full check name). 

The only thing we'd need to maintain manually in this case is category descriptions.

WDYT?


https://reviews.llvm.org/D23848





More information about the cfe-commits mailing list