Git Product home page Git Product logo

stylecopanalyzers.cli's Introduction

StyleCopAnalyzers.CLI

Overview

StyleCop.Analyzers CLI tool

Description

StyleCopAnalyzers.CLI is a tool to check C# coding style with CLI, commit-hook, etc.

Requirement

  • .NET Core SDK or Runtime ver2.1 or higher. .NET Core

Usage

Execute by specifying solution file, csproj file and directory.

  • Check in the default ruleset of StyleCop.Analyzers
dotnet ./StyleCopAnalyzers.CLI.dll check [./ExampleDir or ./Example.sln or ./Example.csproj]
  • Specify a StyleCop.Analyzers ruleset
dotnet ./StyleCopAnalyzers.CLI.dll check -r stylecop.ruleset  [./ExampleDir or ./Example.sln or ./Example.csproj]
  • Specify a stylecop.json
dotnet ./StyleCopAnalyzers.CLI.dll check -j stylecop.json  [./ExampleDir or ./Example.sln or ./Example.csproj]
  • Both ruleset and json can be specified
dotnet ./StyleCopAnalyzers.CLI.dll check -j stylecop.json -r stylecop.ruleset [./ExampleDir or ./Example.sln or ./Example.csproj]
  • Fix Style
dotnet ./StyleCopAnalyzers.CLI.dll fix -j stylecop.json -r stylecop.ruleset [./ExampleDir or ./Example.sln or ./Example.csproj]

StyleCheck Running Example

  • Text
# dotnet ./StyleCopAnalyzers.CLI.dll check ./TestCSharpCodes/
SA1402 : StyleCopAnalyzers.CLI/DiagnosticWriter/OutputKind.cs : 23: File may only contain a single type
SA1633 : StyleCopAnalyzers.CLI/DiagnosticWriter/OutputKind.cs : 1: The file header is missing or not located at the top of the file.
SA1649 : StyleCopAnalyzers.CLI/DiagnosticWriter/OutputKind.cs : 10: File name should match first type name.
SA1633 : StyleCopAnalyzers.CLI/DiagnosticWriter/IDiagnosticWriter.cs : 1: The file header is missing or not located at the top of the file.
SA1633 : StyleCopAnalyzers.CLI/Extensions.cs : 1: The file header XML is invalid.
SA1633 : StyleCopAnalyzers.CLI/DiagnosticWriter/ConsoleWriter.cs : 1: The file header is missing or not located at the top of the file.
SA1633 : StyleCopAnalyzers.CLI/DiagnosticWriter/XmlWriter.cs : 1: The file header is missing or not located at the top of the file.
SA1101 : StyleCopAnalyzers.CLI/DiagnosticWriter/XmlWriter.cs : 32: Prefix local calls with this
SA1101 : StyleCopAnalyzers.CLI/DiagnosticWriter/XmlWriter.cs : 33: Prefix local calls with this
  • StyleCop Xml format
# dotnet ./StyleCopAnalyzers.CLI.dll check ./TestCSharpCodes/ -f xml
<?xml version="1.0" encoding="utf-8"?>
<StyleCopViolations xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Violations>
    <Violation Section="StyleCopAnalyzers.CLI.OutputKindExtensions" LineNumber="23" Source=StyleCopAnalyzers.CLI/DiagnosticWriter/OutputKind.cs" RuleNamespace="StyleCop.CSharp.MaintainabilityRules" Rule="SA1402">
      <Message>File may only contain a single type</Message>
    </Violation>
    <Violation Section="StyleCopAnalyzers.CLI.OutputKindExtensions" LineNumber="1" Source=StyleCopAnalyzers.CLI/DiagnosticWriter/OutputKind.cs" RuleNamespace="StyleCop.CSharp.DocumentationRules" Rule="SA1633">
      <Message>The file header is missing or not located at the top of the file.</Message>
    </Violation>
    <Violation Section="StyleCopAnalyzers.CLI.OutputKindExtensions" LineNumber="10" Source=StyleCopAnalyzers.CLI/DiagnosticWriter/OutputKind.cs" RuleNamespace="StyleCop.CSharp.DocumentationRules" Rule="SA1649">
      <Message>File name should match first type name.</Message>
    </Violation>
    <Violation LineNumber="1" Source=StyleCopAnalyzers.CLI/DiagnosticWriter/IDiagnosticWriter.cs" RuleNamespace="StyleCop.CSharp.DocumentationRules" Rule="SA1633">
      <Message>The file header is missing or not located at the top of the file.</Message>
    </Violation>
    <Violation Section="StyleCopTester.Extensions" LineNumber="1" Source=StyleCopAnalyzers.CLI/Extensions.cs" RuleNamespace="StyleCop.CSharp.DocumentationRules" Rule="SA1633">
      <Message>The file header XML is invalid.</Message>
    </Violation>

Style Fix Running Example

CLI

CLI Example

Source Code difference

Diff1 Diff2 Diff3

License

Apache License

Author

rookxx

stylecopanalyzers.cli's People

Contributors

rookxx avatar kylexie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.