bbadjari / stylecopcli

Command-line interface to StyleCop source code analyzers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StyleCop CLI

Overview

StyleCop is a tool initially developed by Microsoft that performs static code analysis on source code written in C# to determine whether the code conforms to a defined set of stylistic rules. These rules describe coding conventions and styles that can be enforced. Analysis results are output to an XML file that indicates which rules were violated. Developers can implement their own custom rules if the standard set of rules included with StyleCop does not meet their needs. In January 2010, StyleCop was made an open source project and is currently being hosted here.

StyleCop CLI is a software application written in C# that provides a command-line interface (CLI) to StyleCop source code analyzers, allowing StyleCop to be integrated as part of batch processes. Most notably, StyleCop CLI can be used by continuous integration (CI) tools that aim to include StyleCop analysis results as part of a continuous quality control process.

Features

  • Analyze Visual C# source files referenced in Visual Studio solutions.
  • Analyze Visual C# source files contained in ASP.NET web site directories referenced in Visual Studio solutions.
  • Analyze Visual C# source files referenced in Visual C# projects.
  • Analyze individual Visual C# source files.
  • Recursively search subdirectories for files to analyze.
  • Specify StyleCop settings file to use during analysis.
  • Specify configuration flags to use during analysis.
  • Specify output file to write analysis results to.

Requirements

StyleCop CLI requires that the .NET Framework 4.0 is installed.

Usage

StyleCop CLI can be executed from the Windows Command Processor (a.k.a. the Command Prompt), from within Windows/DOS batch files or any other place CLI applications can be invoked. When executed without providing command-line arguments, usage information is displayed describing the supported commands:

Command Alternate Command Description
-? -help Print help screen containing usage information.
-cs <filePaths> -sourceFiles <filePaths> Visual C# source (*.cs) files to analyze.
-flags <flags> -configurationFlags <flags> Configuration flags to use during analysis (e.g. DEBUG, RELEASE).
-out <filePath> -outputFile <filePath> Output file to write analysis results to.
-proj <filePaths> -projectFiles <filePaths> Visual C# project (*.csproj) files referencing Visual C# source files to analyze.
-r -recursiveSearch Recursively search subdirectories for files to analyze.
-set <filePath> -settingsFile <filePath> StyleCop settings file to use during analysis.
-sln <filePaths> -solutionFiles <filePaths> Visual Studio solution (*.sln) files referencing Visual C# project files to analyze.

<filePath> specifies a path (absolute or relative) to a file.
<filePaths> specifies one or more paths (absolute or relative) to files. File names can include wildcard characters (* or ?).
<flags> specifies one or more configuration flags.

Examples

Print help screen containing usage information:

StyleCopCLI -?

Analyze Fraction.cs, a Visual C# source file:

StyleCopCLI -cs Fraction.cs

Analyze multiple Visual C# source files:

StyleCopCLI -cs Fraction.cs C:\Projects\Program.cs

Use the DEBUG configuration flag during analysis:

StyleCopCLI -cs Fraction.cs -flags DEBUG

Use multiple configuration flags during analysis:

StyleCopCLI -cs Fraction.cs -flags DEBUG RELEASE

Specify output file to write analysis results to:

StyleCopCLI -cs Fraction.cs -out FractionResults.xml

Analyze Data.csproj, a Visual C# project file referencing Visual C# source files:

StyleCopCLI -proj Data.csproj

Analyze multiple Visual C# project files:

StyleCopCLI -proj Data.csproj C:\Projects\Services\Services.csproj

Analyze wildcard Visual C# project files and recursively search subdirectories:

StyleCopCLI -proj C:\Projects\*.csproj -r

Specify StyleCop settings file to use during analysis:

StyleCopCLI -proj Services.csproj -set Settings.StyleCop

Analyze Calculator.sln, a Visual Studio solution file referencing Visual C# project files:

StyleCopCLI -sln Calculator.sln

Analyze multiple Visual Studio solution files:

StyleCopCLI -sln Calculator.sln C:\Projects\ImageEditor.sln

Exit Codes

StyleCop CLI returns an integer representing the application exit code to the calling process upon termination:

Code Description
0 Application executed successfully.
1 Application encountered an error during execution.
2 Application encountered violations during analysis.

Releases

The latest release of this software can be obtained from: https://github.com/bbadjari/stylecopcli

1.4 (1.4.0.0) - May 28, 2012

  • Application now returns integer representing application exit code upon termination (Feature #3528408).
  • Upgraded to StyleCop 4.7.24.0.

1.3.1 (1.3.1.0) - February 5, 2012

  • Visual C# source files contained in subdirectories of ASP.NET web site directories are now included for analysis.
  • Upgraded to VS File 1.2.1.0.

1.3 (1.3.0.0) - February 2, 2012

  • Upgraded to StyleCop 4.7.6.0.
  • Added support for ASP.NET web site directories referenced in solution files that contain Visual C# source files.
  • Upgraded to VS File 1.2.0.0.

1.2 (1.2.0.0) - December 14, 2011

  • User now informed if no source code files to analyze. This can occur when specifying file names using wildcard characters and no matches found.
  • Added ability to use wildcard characters in place of file names and recursively search subdirectories for files to analyze.
  • Upgraded to VS File 1.1.2.0.
  • Added NAnt build file.

1.1.1 (1.1.1.0) - November 1, 2011

  • Non-C# project files are now skipped when reading solution files in SolutionFile class (Bug #3348878).
  • Upgraded to VS File 1.0.1.0.
  • Added missing StyleCop 4.6.3.0 assemblies.

1.1 (1.1.0.0) - October 15, 2011

  • Upgraded to StyleCop 4.6.3.0.
  • Extracted all files in InputFile namespace into separate library: VS File 1.0.0.0.
  • Upgraded to C# CLI 1.1.1.0.
  • Project names containing periods can now be used for analysis (Bug #3348879).
  • Upgraded solution and project to use Visual C# 2010 Express and .NET Framework 4.0.
  • Added ability to specify individual Visual C# source files for analysis.

1.0 (1.0.0.0) - April 23, 2010

  • Initial release.

Copyright & License

Copyright (c) 2010-2012 Bernard Badjari

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

Command-line interface to StyleCop source code analyzers.


Languages

Language:C# 100.0%