Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[BUG][code-analyzer] regex:NoMixedIndentation: False positive on ApexDocs

オープン
#2,012 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript
領域
devtools

調査の方向性

まず regex:NoMixedIndentation ルールの実装とテストを見つけ、報告された Apex クラスおよびメソッドレベルの ApexDoc の例を再現します。ApexDoc のインデントは無視され、それ以外のタブとスペースの混在では引き続き違反が発生し、関連するテストが通過すれば修正完了です。

索引モデルが issue の本文から書いたものです。

説明

Have you tried to resolve this issue yourself first?
  • I confirm I have gone through the above steps and still have an issue to report.
Bug Description

v5.11.0 seems to have introduced a new regex:NoMixedIndentation rule, which flags apex files that use a mixture of tabs and spaces for indentation. However, this is causing false positive results on method-level ApexDoc comments, example below:

/**
 * @description An example of a class-level ApexDoc
 */
public class SomeApexClass {
	/**
	 * @description An example of a method-level ApexDoc
	 * @param bar Some input parameter
	 * @return Some output parameter
	 */
	public Object foo(Object bar) {
		return null; // Not important...
	}
}

ApexDocs are an officially supported comment format, so it doesn't make sense for these to be flagged as a violation.

Output / Logs
jsiders@jsiders-mac salesforce % sf plugins install [email protected]  
removed 4 packages in 6s
@salesforce/cli: Installing plugin [email protected]... installed v5.10.0

jsiders@jsiders-mac salesforce % sf code-analyzer run -t force-app/main/default/classes/SomeApexClass.cls

Streaming logs in real time to:
    /var/folders/8d/0t7sckgj10xcb32zycf088480000gp/T/sfca-2026_03_24_10_52_21_277.log

Selecting rules... done.
Executing rules... done. Executed rules from cpd, pmd, regex.

=== Summary

Found 0 violations.

Additional log information written to:
    /var/folders/8d/0t7sckgj10xcb32zycf088480000gp/T/sfca-2026_03_24_10_52_21_277.log

jsiders@jsiders-mac salesforce % sf plugins install [email protected]                                 
Polling for new version(s) to become available on npm... done
Successfully validated digital signature for @salesforce/plugin-code-analyzer.
Finished digital signature check.
npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm warn deprecated [email protected]: This version is no longer supported. Please see https://eslint.org/version-support for other options.
added 15 packages, removed 51 packages, and changed 93 packages in 8s
@salesforce/cli: Installing plugin [email protected]... installed v5.11.0

jsiders@jsiders-mac salesforce % sf code-analyzer run -t force-app/main/default/classes/SomeApexClass.cls

Streaming logs in real time to:
    /var/folders/8d/0t7sckgj10xcb32zycf088480000gp/T/sfca-2026_03_24_10_50_59_383.log

Selecting rules... done.
Code Analyzer [10:51:1.984]:
    No violations were suppressed by inline suppression markers.

Executing rules... done. Executed rules from regex, cpd, pmd.

Violation file paths relative to '/Users/jsiders/Documents/VSCode/Nasuni/salesforce/force-app/main/default/classes'.
  #   Severity       Rule                       Location                Message                                                                                     
 ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  1   3 (Moderate)   regex:NoMixedIndentation   SomeApexClass.cls:6:1   Leading indentation contains mixed spaces and tabs. To fix this, use either spaces or tabs.
  2   3 (Moderate)   regex:NoMixedIndentation   SomeApexClass.cls:7:1   Leading indentation contains mixed spaces and tabs. To fix this, use either spaces or tabs.
  3   3 (Moderate)   regex:NoMixedIndentation   SomeApexClass.cls:8:1   Leading indentation contains mixed spaces and tabs. To fix this, use either spaces or tabs.
  4   3 (Moderate)   regex:NoMixedIndentation   SomeApexClass.cls:9:1   Leading indentation contains mixed spaces and tabs. To fix this, use either spaces or tabs.



=== Summary

Found 4 violation(s) across 1 file(s):
    4 Moderate severity violation(s) found.

Additional log information written to:
    /var/folders/8d/0t7sckgj10xcb32zycf088480000gp/T/sfca-2026_03_24_10_50_59_383.log
Steps To Reproduce
  1. Create an Apex class which implements a method-level ApexDoc comment block (example above)
  2. Install [email protected]
  3. Run code-analyzer against the apex class
  4. Observe 0 violations
  5. Install [email protected]
  6. Run code-analyzer against this same class
  7. Observe 1 regex:NoMixedIndentation violation (moderate) for each line of the method-level ApexDoc comment.
Expected Behavior

ApexDocs should not trigger this violation.

All other instances of mixed tabs/spaces should trigger this violation.

Operating System

macOS Tahoe 26.3

Salesforce CLI Version

@salesforce/cli/2.126.4 darwin-arm64 node-v22.20.0

Code Analyzer Plugin (code-analyzer) Version

5.11.0

Node Version

v22.20.0

Java Version

openjdk version "17.0.13" 2024-10-15

Python Version

Python 3.13.1

Additional Context (Screenshots, Files, etc)

No response

Workaround

Reduce the severity of the rule to Low or Info, though this is not ideal for users who wish to report genuine violations.

Urgency

Low

主要言語
TypeScript
スター
240
フォーク
52
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

forcedotcom/code-analyzer のほかの issue

forcedotcom/code-analyzer の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。