如何让C#Arcanist linter工作?

时间:2015-01-08 00:08:40

标签: c# lint arcanist

以下是我运行arc linters --verbose时的说法:

AVAILABLE   csharp (C#)

Configuration Options

severity (optional map<string|int, string>)
  Provide a map from lint codes to adjusted severity levels: error,
  warning, advice, autofix or disabled.

severity.rules (optional map<string, string>)
  Provide a map of regular expressions to severity levels. All matching
  codes have their severity adjusted.

discovery (map<string, list<string>>)
  Provide a discovery map.

binary (string)
  Override default binary.

什么是发现地图?它不会告诉你它是什么,但你必须拥有它。不幸的是,源代码没有启发我。

二进制...我不想覆盖默认二进制文件...什么是默认二进制文件?我必须覆盖它,所以我需要得到一个?我在哪里可以获得与Arcanist兼容的C#linter二进制文件?我能找到的唯一一个是https://github.com/hach-que/cstools,但它会引发异常。

如果我可以添加更多信息,请告诉我。

1 个答案:

答案 0 :(得分:1)

cstools是你需要的;如果你查看ArcanistCSharpLinter.php,你可以看到它,它在那里查找cslint.exe作为默认二进制文件。

---编辑---

不确定你是否正在寻找合适的工具;被提及的是由hach-que开发的这个,这里: https://github.com/hach-que/cstools

我对这个linter并不是很熟悉(不要自己做任何严肃的C#开发),但是在源代码中快速查看一下,发现地图只是一个名为“discovery”的字符串映射, linter的设置。

另请参阅:https://github.com/hach-que/cstools/issues/1

复制粘贴示例,因为这似乎是SO政策:

示例.arcconfig:

{
    "project_id": "Tychaia",
    "conduit_uri": "https://code.redpointsoftware.com.au/",
    "arc.autostash": true,
    "load": [
        "Build/Arcanist"
    ],
    "unit.engine": "XUnitTestEngine",
    "unit.csharp.xunit.binary": "packages/xunit.runners.1.9.1/tools/xunit.console.clr4.exe",
    "unit.csharp.cscover.binary": "cstools/cscover/bin/Debug/cscover.exe",
    "unit.csharp.coverage.match": "/^Tychaia.*\\.(dll|exe)$/",
    "unit.csharp.discovery": {
      "([^/]+)/(.*?)\\.cs": [
        [ "$1.Tests/$1.Tests.Linux.csproj", "$1.Tests/bin/Debug/$1.Tests.dll" ],
        [ "$1.Tests/$1.Tests.Windows.csproj", "$1.Tests/bin/Debug/$1.Tests.dll" ]
      ],
      "([^\\\\]+)\\\\(.*?)\\.cs": [
        [ "$1.Tests\\$1.Tests.Windows.csproj", "$1.Tests\\bin\\Debug\\$1.Tests.dll" ]
      ],
      "([^/]+)\\.Tests/(.*?)\\.cs": [
        [ "$1.Tests/$1.Tests.Linux.csproj", "$1.Tests/bin/Debug/$1.Tests.dll" ],
        [ "$1.Tests/$1.Tests.Windows.csproj", "$1.Tests/bin/Debug/$1.Tests.dll" ]
      ],
      "([^\\\\]+)\\.Tests\\\\(.*?)\\.cs": [
        [ "$1.Tests\\$1.Tests.Windows.csproj", "$1.Tests\\bin\\Debug\\$1.Tests.dll" ]
      ]
    }
}

示例.arclint:

{
  "linters": {
    "csharp": {
      "type": "csharp",
      "include": "(\\.cs$)",
      "exclude": [ "(\\.Designer\\.cs$)", "(Phabricator\\.Conduit(.*+))", "(TychaiaProfilerEntityUtil\\.cs)" ],
      "binary": "cstools/cslint/bin/Debug/cslint.exe",
      "discovery": {
        "([^/]+)/(.*?)\\.cs": [
          "$1/$1.Linux.csproj"
        ],
        "([^\\\\]+)\\\\(.*?)\\.cs": [
          "$1\\$1.Windows.csproj"
        ]
      }
    },
    "license": {
      "type": "tychaialicense",
      "include": "(\\.cs$)",
      "exclude": [ "(\\.Designer\\.cs$)", "(Phabricator\\.Conduit(.*+))", "(TychaiaProfilerEntityUtil\\.cs)" ]
    }
  }
}

无论如何,如果你在使cstools工作时遇到困难,我建议在Github回购中打开一个问题;他似乎非常敏感。此外,作为一名开源开发人员,听到其他人正在使用您的作品总是很棒。