DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.64k stars 506 forks source link

CLI? #2571

Open alexreg opened 6 years ago

alexreg commented 6 years ago

Does StyleCop.Analyzers have a command-line interface? Can it be run via the msbuild command-line even? This would be especially useful on Mono, where there is no code analysis integration in Xamarin Studio.

llehn commented 6 years ago

Used as a nuget package, it integrates into the build. No CLI needed.

alexreg commented 6 years ago

You say "needed", but actually a CLI is sometimes desirable over integration... in this case though, I have since learnt that you cannot do the static analysis without building (which is rather odd)... so I guess this is a no-go.

llehn commented 6 years ago

Well its a roslyn based analyzer, it has to build to do its work, since roslyn is a compiler.

Out of curiousity, in what scenario would a CLI be more useful than an integration?

alexreg commented 6 years ago

Need not perform every stage of the build though, I was thinking.

Would be more useful for automation, e.g. CI. With some MSBuild parameters though (I have a separate issue on that), this issue could be alleviated.

andreacassioli commented 6 years ago

I agree having a proper CLI would be terrific, especially when it comes to CI.

andreacassioli commented 6 years ago

Having a CLI utility would be amazing to work both with CI but also as git commit hook.

kostyaVyrodov commented 5 years ago

Agree with the comments above. Currently we have an issue: we are going to support legacy solution (23 project) and it has over 30K warnings. I thought, it would be super if we could run StyleCop for only those single file that were updated to fix warnings. Maybe, it's possible, but I has to integrate it with CI and I didn't find any possible solutions to lint a file, except pressing on the button 'Run StyleCop' in the VS2017.

cjavdev commented 4 years ago

Is this still true? I'm helping maintain client libraries / bindings in many different languages: ruby, python, js, java, kotlin, and c#. As part of this project, I'm shelling out to various language specific cli tools for linting snippets of code for documentation. Would love any pointers for running StyleCop against my c# snippets from the CLI (mac/unix)

andreacassioli commented 4 years ago

Hey maintainers, any thoughts about this issue after years of silence?

elachlan commented 4 years ago

I found this but didn't get around to trying it.

https://github.com/kzu/AutoCodeFix