github / github/codeql

[Rust] How do I query function and module attributes?

未關閉
#20,771 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
question Rust
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 15 小時
30 天內合併 PR
141

描述

I wanted to filter out tests from my results, based on if they either had a #[test] attribute or #[cfg(test)].

Currently tried something similar to this but cant figure out how to properly filter this from the docs

```ql
predicate doesntWork(Module mod, Attr a, Meta m) {
a = mod.getAnAttr() and
m = a.getMeta() and
m.hasPath() and
m.getPath().toString() = "cfg" and
m.hasTokenTree()
}
```

貢獻指南

開啟貢獻指南

研究方向

Start by locating the Rust CodeQL library definitions for Module, Attr, and Meta, then compare how the #[test] and #[cfg(test)] attributes are represented. Done means providing a documented query pattern that filters tests using these attributes.

由索引模型根據 Issue 內容生成。

評估

技術堆疊
rust
領域
devtools
Issue 類型
文件
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。