[BUG][code-analyzer] regex:NoMixedIndentation: False positive on ApexDocs
还没有人认领这个 Issue。
评估
- 难度
- 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 code-analyzer@5.10.0
removed 4 packages in 6s
@salesforce/cli: Installing plugin code-analyzer@5.10.0... 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 code-analyzer@5.11.0
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 rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated eslint@8.57.1: 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 code-analyzer@5.11.0... 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
- Create an Apex class which implements a method-level ApexDoc comment block (example above)
- Install
code-analyzer@5.10.0 - Run code-analyzer against the apex class
- Observe 0 violations
- Install
code-analyzer@5.11.0 - Run code-analyzer against this same class
- Observe 1
regex:NoMixedIndentationviolation (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
- 平均合并
- 9 小时 48 分钟
- 30 天内合并 PR
- 3
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
forcedotcom/code-analyzer 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
forcedotcom/code-analyzer#2094 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
forcedotcom/code-analyzer#2093 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
forcedotcom/code-analyzer#2091 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
forcedotcom/code-analyzer#2090 ·
-
难度 4/5 3-5 天 新手友好度 45/100
forcedotcom/code-analyzer#2099 ·
查看 forcedotcom/code-analyzer 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
bug v2
难度 2/5 1-3 小时 新手友好度 75/100
modelcontextprotocol/inspector#2458 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
难度 2/5 1-3 小时 新手友好度 70/100
carbon-design-system/ibm-products#9907 ·