【问题标题】:phpcs with VScode - how do I disable the line length warning?带有VScode的phpcs - 如何禁用行长警告?
【发布时间】:2020-03-05 06:19:14
【问题描述】:

我正在处理一些遗留代码,而 VScode 正在突出显示很多行,因为有一些警告,例如 Line exceeds 85 characters, contains 91 characters。这很烦人,我想将该限制提高到至少 120 个字符,甚至完全禁用它。 我的垂直标尺已经设置为 120。

如何移动或删除该限制?我一直在到处寻找,但找不到有效的答案……这是我项目的settings.json

{
    "editor.wordWrapColumn": 120
}

【问题讨论】:

  • 我已经通过将警告严重性设置设置为 6 来部分解决它......至少我不再有这些警告了。
  • 您是如何将警告严重性设置为 6 的?
  • 在 settings.json 中添加"phpcs.warningSeverity": 6

标签: visual-studio-code phpcs


【解决方案1】:

在 VS Code 中编辑 phpcs 设置并确保“PHP Sniffer: Standard”为空白(以便它查找您的自定义规则集文件)。

在您的项目根目录中创建文件“phpcs.xml”,其中包含如下规则集:

<?xml version="1.0"?>
<ruleset name="MyRuleset">
  <!-- Scan all files in directory -->
  <file>.</file>

  <!-- Ignore Composer dependencies -->
  <exclude-pattern>vendor/</exclude-pattern>

  <!-- Show colors in console -->
  <arg value="-colors"/>

  <!-- Show sniff codes in all reports -->
  <arg value="ns"/>

  <!-- Use PSR-12 as a base -->
  <rule ref="PSR12"/>

  <rule ref="Generic.Files.LineLength.TooLong">
      <severity>0</severity>
  </rule>
</ruleset>

【讨论】:

  • 对我不起作用。我收到错误phpcs: The "c:\Users\paul\OneDrive\Games\Scratch\Shops\PP\Site\phpcs.xml" coding standard is not installed. Please review your configuration an try again.
猜你喜欢
  • 1970-01-01
  • 2017-07-26
  • 2013-04-08
  • 2017-01-31
  • 2021-12-04
  • 2017-12-23
  • 2021-08-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多