Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ for historical reference.

### Added

- `bca report markdown|html` now honors in-source suppression markers
(`bca: suppress`, `bca: suppress-file`, `#lizard forgives`) **by
default**, omitting a function from a metric's hotspot table when that
metric is suppressed for it — matching `bca check` and the SARIF
emitter (the report previously listed raw values and re-surfaced every
silenced function). Suppression is per-metric and folds the file's
`suppress-file` scope into each function's own scope. `bca report
--no-suppress` (or `[report] no_suppress = true` in `bca.toml`) opts
into the raw audit view that lists every offender. Advisory roll-ups
(the actionable summary, CC-stats note) intentionally keep counting
raw measurements. `SuppressionScope::merge` is now `pub` (additive) so
report consumers can fold scopes
([#501](https://github.com/dekobon/big-code-analysis/issues/501)).
- `bca check --report-suppressed`: surface the debt the gate tolerates in
the code-scan document instead of dropping it. Offenders silenced by an
in-source `bca: suppress` marker or covered by the baseline stay out of
Expand Down Expand Up @@ -423,6 +436,13 @@ for historical reference.

### Changed

- Python bindings: `lang_to_name` now delegates to `LANG::get_name()`
for all but three lookup-token overrides (`Cpp` → `"cpp"`, `Csharp` →
`"csharp"`, `Tsx` → `"tsx"`), collapsing a 22-arm hand-maintained
table that duplicated the upstream CLI display names. The Python-facing
`language` identifiers are byte-identical for every variant; this only
removes drift risk between the facade and the CLI display names
([#500](https://github.com/dekobon/big-code-analysis/issues/500)).
- **(breaking)** `FilesData` and `ConcurrentRunner` are reshaped into a
terminal file-set processor: `FilesData` drops its `include` /
`exclude` `GlobSet` fields (now just `FilesData { paths }`),
Expand Down
28 changes: 28 additions & 0 deletions big-code-analysis-book/src/commands/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,36 @@ bca --paths /path/to/project report markdown --output report.md
| --- | --- | --- |
| `--top N` | 20 | Maximum entries per hotspot table. |
| `--strip-prefix PATH` | *(empty)* | Prefix removed from file paths. |
| `--no-suppress` | *(off)* | Include functions silenced by in-source suppression markers (raw audit view). |
| `-o, --output FILE` | *(stdout)* | Output file. Parent directory must exist. |

## Suppression markers

By default, `bca report markdown|html` **honours** in-source suppression
markers — the same `// bca: suppress`, `// bca: suppress-file`, and
`#lizard forgives` comments that [`bca check`](check.md) and the SARIF
emitter respect (see [Suppression](suppression.md)). A function is
omitted from a metric's hotspot table when that metric is suppressed for
it, so the published report agrees with the threshold gate instead of
re-surfacing every silenced offender.

Suppression is per-metric: a `// bca: suppress(cyclomatic)` marker drops
the function from the Cyclomatic table only — it still appears in the
Cognitive, Halstead, and other tables. A bare `// bca: suppress` (or
`// bca: suppress-file`) covers every metric.

Pass `--no-suppress` for the raw audit view that lists every offender
regardless of markers. The setting can also be pinned in the
[`bca.toml` manifest](check.md):

```toml
[report]
no_suppress = true
```

The CLI flag wins; a bare `--no-suppress` can force the audit view on,
but the manifest never forces it off.

## Examples

Show only the five worst hotspots per section:
Expand Down
16 changes: 10 additions & 6 deletions big-code-analysis-book/src/commands/suppression.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ In-source suppression markers silence threshold violations without
editing the offending function or excluding the file from the walk.
Drop a marker in any comment in the source file and `bca check`
treats the covered metrics as if they were within limits for that
scope. Metric computation is unaffected — raw `bca metrics` /
`bca report` output still reports every number. Suppression is a
threshold-check concern only.
scope. Metric computation is unaffected — raw `bca metrics` output
still reports every number. Suppression is a measurement-display
concern: `bca check` drops the covered violations from the gate, and
`bca report markdown|html` omits the covered functions from the
matching hotspot tables by default (pass `bca report --no-suppress`
for the raw audit view — see [report](report.md)).

Markers exist for the cases editing the code is not an option:
generated-style legacy modules awaiting rewrite, accepted exceptions
Expand Down Expand Up @@ -179,9 +182,10 @@ offender list:
bca --paths src/ check --no-suppress
```

The flag has no effect on metric values themselves: raw
`bca metrics` / `bca report` output already ignores markers, since
suppression is a threshold-check concern only.
The flag has no effect on metric values themselves: raw `bca metrics`
output always reports every number. `bca report markdown|html` honours
markers in its hotspot tables by default and accepts its own
[`--no-suppress`](report.md) flag for the same raw audit view.

## Surfacing suppressed debt (`--report-suppressed`)

Expand Down
29 changes: 25 additions & 4 deletions big-code-analysis-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,9 @@ pub fn run() {
Command::Functions => run_command_functions(cli.globals, preproc),
Command::Metrics(args) => run_command_metrics(cli.globals, args, preproc),
Command::Ops(args) => run_command_ops(cli.globals, args, preproc),
Command::Report(args) => run_command_report(cli.globals, args, preproc),
Command::Report(args) => {
run_command_report(cli.globals, args, manifest.as_ref(), preproc);
}
Command::Find(args) => run_command_find(cli.globals, args, preproc),
Command::Count(args) => run_command_count(cli.globals, args, preproc),
Command::StripComments(args) => run_command_strip_comments(cli.globals, args, preproc),
Expand Down Expand Up @@ -1563,7 +1565,16 @@ fn run_command_ops(
run_walk(globals, cfg);
}

fn run_command_report(globals: GlobalOpts, args: ReportArgs, preproc: Option<Arc<PreprocResults>>) {
fn run_command_report(
globals: GlobalOpts,
mut args: ReportArgs,
manifest: Option<&Manifest>,
preproc: Option<Arc<PreprocResults>>,
) {
if let Some(m) = manifest {
m.merge_report(&mut args);
}
let policy = SuppressionPolicy::from_no_suppress(args.no_suppress);
if let Some(ref output) = args.output {
if output.exists() && output.is_dir() {
die("--output must be a file path for `report`");
Expand All @@ -1590,8 +1601,8 @@ fn run_command_report(globals: GlobalOpts, args: ReportArgs, preproc: Option<Arc
// All worker threads have joined, so `rx.into_iter()` terminates.
let summaries: Vec<FunctionSummary> = rx.into_iter().collect();
let report = match args.format {
ReportFormat::Markdown => generate_report(&summaries, args.top as usize),
ReportFormat::Html => generate_html_report(&summaries, args.top as usize),
ReportFormat::Markdown => generate_report(&summaries, args.top as usize, policy),
ReportFormat::Html => generate_html_report(&summaries, args.top as usize, policy),
};
if let Some(ref output_path) = args.output {
std::fs::write(output_path, &report)
Expand Down Expand Up @@ -1739,6 +1750,16 @@ nargs = 7
nexits = 5
abc = 50
wmc = 60

# Aggregated-report options for `bca report markdown|html` (#501). By
# default the report honours in-source suppression markers
# (`bca: suppress`, `bca: suppress-file`, `#lizard forgives`) and omits a
# function from a metric's hotspot table when that metric is suppressed
# for it — matching `bca check` and the SARIF emitter. Uncomment to opt
# into the raw audit view that lists every offender (equivalent to
# `bca report --no-suppress`).
# [report]
# no_suppress = true
";

/// Canonical contents of a freshly-scaffolded `.bcaignore`. The
Expand Down
Loading
Loading