1#[path = "dead_code_codeclimate_component_health.rs"]
4mod component_health;
5
6use std::path::Path;
7
8use fallow_config::{RulesConfig, Severity};
9use fallow_output::{
10 CodeClimateIssue, CodeClimateIssueInput, CodeClimateSeverity, build_codeclimate_issue,
11 codeclimate_fingerprint_hash, normalize_uri,
12};
13use fallow_types::envelope::AuditIntroduced;
14use fallow_types::identity::dead_code_finding_id;
15use fallow_types::output_dead_code::{
16 EffectiveSeverity, GatedFinding, ReachabilityCaveat, caveat_suffix,
17};
18use fallow_types::results::AnalysisResults;
19
20#[path = "dead_code_codeclimate_caller_review.rs"]
21mod caller_review;
22#[path = "dead_code_codeclimate_catalog.rs"]
23mod catalog_issues;
24#[path = "dead_code_codeclimate_component_io.rs"]
25mod component_io;
26#[path = "dead_code_codeclimate_namespace_escape.rs"]
27mod namespace_escape;
28#[path = "dead_code_codeclimate_test_only_export.rs"]
29mod test_only_export;
30use caller_review::{push_absent_component_prop_issues, push_constant_parameter_issues};
31use catalog_issues::{
32 push_empty_catalog_group_issues, push_misconfigured_dependency_override_issues,
33 push_unresolved_catalog_reference_issues, push_unused_catalog_entry_issues,
34 push_unused_dependency_override_issues,
35};
36use component_io::{
37 push_unused_component_input_issues, push_unused_component_output_issues,
38 push_unused_svelte_event_issues,
39};
40
41fn severity_to_codeclimate(s: Severity) -> CodeClimateSeverity {
42 match s {
43 Severity::Error => CodeClimateSeverity::Major,
44 Severity::Warn => CodeClimateSeverity::Minor,
45 Severity::Off => unreachable!(),
46 }
47}
48
49fn gate_codeclimate(effective: Option<EffectiveSeverity>, rule: Severity) -> CodeClimateSeverity {
56 match effective {
57 Some(EffectiveSeverity::Error) => CodeClimateSeverity::Major,
58 Some(EffectiveSeverity::Warn) => CodeClimateSeverity::Minor,
59 None => match rule {
60 Severity::Off => CodeClimateSeverity::Minor,
61 Severity::Error | Severity::Warn => severity_to_codeclimate(rule),
62 },
63 }
64}
65
66fn finding_codeclimate(finding: &impl GatedFinding, rule: Severity) -> CodeClimateSeverity {
67 gate_codeclimate(finding.effective_severity(), rule)
68}
69
70fn cc_path(path: &Path, root: &Path) -> String {
71 normalize_uri(
72 &path
73 .strip_prefix(root)
74 .unwrap_or(path)
75 .display()
76 .to_string(),
77 )
78}
79
80fn cc_caveat_suffix(caveats: &[ReachabilityCaveat]) -> String {
95 caveat_suffix(caveats).unwrap_or_default()
96}
97
98fn dead_code_issue(
121 finding_id: Option<&str>,
122 introduced: Option<AuditIntroduced>,
123 discriminator: &[&str],
124 input: CodeClimateIssueInput<'_>,
125) -> CodeClimateIssue {
126 let mut issue = build_codeclimate_issue(input);
127 issue.audit = introduced.map(|AuditIntroduced(introduced)| audit_review_context(introduced));
128 if let Some(id) = finding_id {
129 let mut parts = Vec::with_capacity(discriminator.len() + 1);
130 parts.push(id);
131 parts.extend_from_slice(discriminator);
132 let stable = codeclimate_fingerprint_hash(&parts);
133 if stable != issue.fingerprint {
134 issue.legacy_fingerprint = Some(std::mem::replace(&mut issue.fingerprint, stable));
135 }
136 }
137 issue
138}
139
140pub(crate) const fn audit_review_context(introduced: bool) -> fallow_output::AuditReviewContext {
143 fallow_output::AuditReviewContext {
144 attribution: if introduced {
145 fallow_output::AuditFindingAttribution::Introduced
146 } else {
147 fallow_output::AuditFindingAttribution::Inherited
148 },
149 gate_exemption: None,
150 gate: None,
151 }
152}
153
154fn location_discriminators(locations: &[(String, u32, u32)]) -> Vec<Vec<String>> {
165 locations
166 .iter()
167 .enumerate()
168 .map(|(index, (path, line, col))| {
169 let earlier = locations
170 .iter()
171 .enumerate()
172 .filter(|(other, (other_path, other_line, other_col))| {
173 other_path == path && (other_line, other_col, *other) < (line, col, index)
174 })
175 .count();
176 if earlier == 0 {
177 vec![path.clone()]
178 } else {
179 vec![path.clone(), format!("~{earlier}")]
180 }
181 })
182 .collect()
183}
184
185fn push_dep_cc_issues<'a, I>(
187 issues: &mut Vec<CodeClimateIssue>,
188 deps: I,
189 root: &Path,
190 rule_id: &str,
191 location_label: &str,
192 severity: Severity,
193) where
194 I: IntoIterator<
195 Item = (
196 &'a fallow_types::results::UnusedDependency,
197 &'a [ReachabilityCaveat],
198 Option<EffectiveSeverity>,
199 Option<&'a str>,
200 Option<AuditIntroduced>,
201 ),
202 >,
203{
204 for (dep, caveats, effective, finding_id, introduced) in deps {
205 let level = gate_codeclimate(effective, severity);
206 let path = cc_path(&dep.path, root);
207 let line = if dep.line > 0 { Some(dep.line) } else { None };
208 let fp = codeclimate_fingerprint_hash(&[rule_id, &dep.package_name]);
209 let workspace_context = if dep.used_in_workspaces.is_empty() {
210 String::new()
211 } else {
212 let workspaces = dep
213 .used_in_workspaces
214 .iter()
215 .map(|path| cc_path(path, root))
216 .collect::<Vec<_>>()
217 .join(", ");
218 format!("; imported in other workspaces: {workspaces}")
219 };
220 issues.push(dead_code_issue(
221 finding_id,
222 introduced,
223 &[],
224 CodeClimateIssueInput {
225 check_name: rule_id,
226 description: &format!(
227 "Package '{}' is in {location_label} but never imported{workspace_context}{}",
228 dep.package_name,
229 cc_caveat_suffix(caveats)
230 ),
231 severity: level,
232 category: "Bug Risk",
233 path: &path,
234 begin_line: line,
235 fingerprint: &fp,
236 },
237 ));
238 }
239}
240
241fn push_unused_file_issues(
242 issues: &mut Vec<CodeClimateIssue>,
243 files: &[fallow_types::output_dead_code::UnusedFileFinding],
244 root: &Path,
245 severity: Severity,
246) {
247 if files.is_empty() {
248 return;
249 }
250 for entry in files {
251 let level = finding_codeclimate(entry, severity);
252 let path = cc_path(&entry.file.path, root);
253 let fp = codeclimate_fingerprint_hash(&["fallow/unused-file", &path]);
254 issues.push(dead_code_issue(
255 entry.finding_id.as_deref(),
256 entry.introduced,
257 &[],
258 CodeClimateIssueInput {
259 check_name: "fallow/unused-file",
260 description: &format!(
261 "File is not reachable from any entry point{}",
262 cc_caveat_suffix(&entry.reachability_caveats)
263 ),
264 severity: level,
265 category: "Bug Risk",
266 path: &path,
267 begin_line: None,
268 fingerprint: &fp,
269 },
270 ));
271 }
272}
273
274struct UnusedExportIssuesInput<'a, I> {
280 issues: &'a mut Vec<CodeClimateIssue>,
281 exports: I,
282 root: &'a Path,
283 rule_id: &'a str,
284 direct_label: &'a str,
285 re_export_label: &'a str,
286 severity: Severity,
287}
288
289fn push_unused_export_issues<'a, I>(input: UnusedExportIssuesInput<'a, I>)
290where
291 I: IntoIterator<
292 Item = (
293 &'a fallow_types::results::UnusedExport,
294 &'a [ReachabilityCaveat],
295 Option<EffectiveSeverity>,
296 Option<&'a str>,
297 Option<AuditIntroduced>,
298 ),
299 >,
300{
301 for (export, caveats, effective, finding_id, introduced) in input.exports {
302 let level = gate_codeclimate(effective, input.severity);
303 let path = cc_path(&export.path, input.root);
304 let kind = if export.is_re_export {
305 input.re_export_label
306 } else {
307 input.direct_label
308 };
309 let line_str = export.line.to_string();
310 let fp =
311 codeclimate_fingerprint_hash(&[input.rule_id, &path, &line_str, &export.export_name]);
312 input.issues.push(dead_code_issue(
313 finding_id,
314 introduced,
315 &[],
316 CodeClimateIssueInput {
317 check_name: input.rule_id,
318 description: &format!(
319 "{kind} '{}' is never imported by other modules{}",
320 export.export_name,
321 cc_caveat_suffix(caveats)
322 ),
323 severity: level,
324 category: "Bug Risk",
325 path: &path,
326 begin_line: Some(export.line),
327 fingerprint: &fp,
328 },
329 ));
330 }
331}
332
333fn push_private_type_leak_issues(
334 issues: &mut Vec<CodeClimateIssue>,
335 leaks: &[fallow_types::output_dead_code::PrivateTypeLeakFinding],
336 root: &Path,
337 severity: Severity,
338) {
339 if leaks.is_empty() {
340 return;
341 }
342 for entry in leaks {
343 let level = finding_codeclimate(entry, severity);
344 let leak = &entry.leak;
345 let path = cc_path(&leak.path, root);
346 let line_str = leak.line.to_string();
347 let fp = codeclimate_fingerprint_hash(&[
348 "fallow/private-type-leak",
349 &path,
350 &line_str,
351 &leak.export_name,
352 &leak.type_name,
353 ]);
354 issues.push(dead_code_issue(
355 entry.finding_id.as_deref(),
356 entry.introduced,
357 &[],
358 CodeClimateIssueInput {
359 check_name: "fallow/private-type-leak",
360 description: &format!(
361 "Export '{}' references private type '{}'",
362 leak.export_name, leak.type_name
363 ),
364 severity: level,
365 category: "Bug Risk",
366 path: &path,
367 begin_line: Some(leak.line),
368 fingerprint: &fp,
369 },
370 ));
371 }
372}
373
374fn push_deprecated_export_issues(
375 issues: &mut Vec<CodeClimateIssue>,
376 findings: &[fallow_types::output_dead_code::DeprecatedExportInUseFinding],
377 root: &Path,
378 severity: Severity,
379) {
380 for entry in findings {
381 let level = finding_codeclimate(entry, severity);
382 let export = &entry.export;
383 let path = cc_path(&export.path, root);
384 let line_str = export.line.to_string();
385 let fp = codeclimate_fingerprint_hash(&[
386 "fallow/deprecated-export-in-use",
387 &path,
388 &line_str,
389 &export.export_name,
390 ]);
391 issues.push(dead_code_issue(
392 entry.finding_id.as_deref(),
393 entry.introduced,
394 &[],
395 CodeClimateIssueInput {
396 check_name: "fallow/deprecated-export-in-use",
397 description: &export.description(),
398 severity: level,
399 category: "Compatibility",
400 path: &path,
401 begin_line: Some(export.line),
402 fingerprint: &fp,
403 },
404 ));
405 }
406}
407
408fn push_type_only_dep_issues(
409 issues: &mut Vec<CodeClimateIssue>,
410 deps: &[fallow_types::output_dead_code::TypeOnlyDependencyFinding],
411 root: &Path,
412 severity: Severity,
413) {
414 if deps.is_empty() {
415 return;
416 }
417 for entry in deps {
418 let level = finding_codeclimate(entry, severity);
419 let dep = &entry.dep;
420 let path = cc_path(&dep.path, root);
421 let line = if dep.line > 0 { Some(dep.line) } else { None };
422 let fp = codeclimate_fingerprint_hash(&["fallow/type-only-dependency", &dep.package_name]);
423 issues.push(dead_code_issue(
424 entry.finding_id.as_deref(),
425 entry.introduced,
426 &[],
427 CodeClimateIssueInput {
428 check_name: "fallow/type-only-dependency",
429 description: &format!(
430 "Package '{}' is only imported via type-only imports (consider moving to devDependencies)",
431 dep.package_name
432 ),
433 severity: level,
434 category: "Bug Risk",
435 path: &path,
436 begin_line: line,
437 fingerprint: &fp,
438 },
439 ));
440 }
441}
442
443fn push_test_only_dep_issues(
444 issues: &mut Vec<CodeClimateIssue>,
445 deps: &[fallow_types::output_dead_code::TestOnlyDependencyFinding],
446 root: &Path,
447 severity: Severity,
448) {
449 if deps.is_empty() {
450 return;
451 }
452 for entry in deps {
453 let level = finding_codeclimate(entry, severity);
454 let dep = &entry.dep;
455 let path = cc_path(&dep.path, root);
456 let line = if dep.line > 0 { Some(dep.line) } else { None };
457 let fp = codeclimate_fingerprint_hash(&["fallow/test-only-dependency", &dep.package_name]);
458 issues.push(dead_code_issue(
459 entry.finding_id.as_deref(),
460 entry.introduced,
461 &[],
462 CodeClimateIssueInput {
463 check_name: "fallow/test-only-dependency",
464 description: &format!(
465 "Package '{}' is only imported by test files (consider moving to devDependencies)",
466 dep.package_name
467 ),
468 severity: level,
469 category: "Bug Risk",
470 path: &path,
471 begin_line: line,
472 fingerprint: &fp,
473 },
474 ));
475 }
476}
477
478fn push_dev_dep_in_prod_issues(
479 issues: &mut Vec<CodeClimateIssue>,
480 deps: &[fallow_types::output_dead_code::DevDependencyInProductionFinding],
481 root: &Path,
482 severity: Severity,
483) {
484 if deps.is_empty() {
485 return;
486 }
487 for entry in deps {
488 let level = finding_codeclimate(entry, severity);
489 let dep = &entry.dep;
490 let path = cc_path(&dep.path, root);
491 let line = if dep.line > 0 { Some(dep.line) } else { None };
492 let fp = codeclimate_fingerprint_hash(&[
493 "fallow/dev-dependency-in-production",
494 &dep.package_name,
495 ]);
496 issues.push(dead_code_issue(
497 entry.finding_id.as_deref(),
498 entry.introduced,
499 &[],
500 CodeClimateIssueInput {
501 check_name: "fallow/dev-dependency-in-production",
502 description: &format!(
503 "devDependency '{}' is imported by production code at runtime (consider moving to dependencies)",
504 dep.package_name
505 ),
506 severity: level,
507 category: "Bug Risk",
508 path: &path,
509 begin_line: line,
510 fingerprint: &fp,
511 },
512 ));
513 }
514}
515
516fn push_unused_member_issues<'a, I>(
521 issues: &mut Vec<CodeClimateIssue>,
522 members: I,
523 root: &Path,
524 rule_id: &str,
525 entity_label: &str,
526 severity: Severity,
527) where
528 I: IntoIterator<
529 Item = (
530 &'a fallow_types::results::UnusedMember,
531 &'a [ReachabilityCaveat],
532 Option<EffectiveSeverity>,
533 Option<&'a str>,
534 Option<AuditIntroduced>,
535 ),
536 >,
537{
538 for (member, caveats, effective, finding_id, introduced) in members {
539 let level = gate_codeclimate(effective, severity);
540 let path = cc_path(&member.path, root);
541 let line_str = member.line.to_string();
542 let fp = codeclimate_fingerprint_hash(&[
543 rule_id,
544 &path,
545 &line_str,
546 &member.parent_name,
547 &member.member_name,
548 ]);
549 issues.push(dead_code_issue(
550 finding_id,
551 introduced,
552 &[],
553 CodeClimateIssueInput {
554 check_name: rule_id,
555 description: &format!(
556 "{entity_label} member '{}.{}' is never referenced{}",
557 member.parent_name,
558 member.member_name,
559 cc_caveat_suffix(caveats)
560 ),
561 severity: level,
562 category: "Bug Risk",
563 path: &path,
564 begin_line: Some(member.line),
565 fingerprint: &fp,
566 },
567 ));
568 }
569}
570
571fn push_unresolved_import_issues(
572 issues: &mut Vec<CodeClimateIssue>,
573 imports: &[fallow_types::output_dead_code::UnresolvedImportFinding],
574 root: &Path,
575 severity: Severity,
576) {
577 if imports.is_empty() {
578 return;
579 }
580 for entry in imports {
581 let level = finding_codeclimate(entry, severity);
582 let import = &entry.import;
583 let path = cc_path(&import.path, root);
584 let line_str = import.line.to_string();
585 let fp = codeclimate_fingerprint_hash(&[
586 "fallow/unresolved-import",
587 &path,
588 &line_str,
589 &import.specifier,
590 ]);
591 issues.push(dead_code_issue(
592 entry.finding_id.as_deref(),
593 entry.introduced,
594 &[],
595 CodeClimateIssueInput {
596 check_name: "fallow/unresolved-import",
597 description: &format!("Import '{}' could not be resolved", import.specifier),
598 severity: level,
599 category: "Bug Risk",
600 path: &path,
601 begin_line: Some(import.line),
602 fingerprint: &fp,
603 },
604 ));
605 }
606}
607
608fn push_unlisted_dep_issues(
609 issues: &mut Vec<CodeClimateIssue>,
610 deps: &[fallow_types::output_dead_code::UnlistedDependencyFinding],
611 root: &Path,
612 severity: Severity,
613) {
614 if deps.is_empty() {
615 return;
616 }
617 for entry in deps {
618 let level = finding_codeclimate(entry, severity);
619 let dep = &entry.dep;
620 let sites: Vec<(String, u32, u32)> = dep
621 .imported_from
622 .iter()
623 .map(|site| (cc_path(&site.path, root), site.line, site.col))
624 .collect();
625 let discriminators = location_discriminators(&sites);
626 for ((path, line, _), discriminator) in sites.iter().zip(&discriminators) {
627 let line_str = line.to_string();
628 let discriminator: Vec<&str> = discriminator.iter().map(String::as_str).collect();
629 let fp = codeclimate_fingerprint_hash(&[
630 "fallow/unlisted-dependency",
631 path,
632 &line_str,
633 &dep.package_name,
634 ]);
635 issues.push(dead_code_issue(
636 entry.finding_id.as_deref(),
637 entry.introduced,
638 &discriminator,
639 CodeClimateIssueInput {
640 check_name: "fallow/unlisted-dependency",
641 description: &format!(
642 "Package '{}' is imported but not listed in package.json",
643 dep.package_name
644 ),
645 severity: level,
646 category: "Bug Risk",
647 path,
648 begin_line: Some(*line),
649 fingerprint: &fp,
650 },
651 ));
652 }
653 }
654}
655
656fn push_unlisted_binary_issues(
657 issues: &mut Vec<CodeClimateIssue>,
658 binaries: &[fallow_types::output_dead_code::UnlistedBinaryFinding],
659 root: &Path,
660 severity: Severity,
661) {
662 for entry in binaries {
663 let level = finding_codeclimate(entry, severity);
664 let binary = &entry.binary;
665 let sites: Vec<(String, u32, u32)> = binary
666 .used_in
667 .iter()
668 .map(|site| (cc_path(&site.path, root), site.line, site.col))
669 .collect();
670 let discriminators = location_discriminators(&sites);
671 for ((path, line, _), discriminator) in sites.iter().zip(&discriminators) {
672 let line_str = line.to_string();
673 let discriminator: Vec<&str> = discriminator.iter().map(String::as_str).collect();
674 let fp = codeclimate_fingerprint_hash(&[
675 "fallow/unlisted-binary",
676 path,
677 &line_str,
678 &binary.binary_name,
679 ]);
680 issues.push(dead_code_issue(
681 entry.finding_id.as_deref(),
682 entry.introduced,
683 &discriminator,
684 CodeClimateIssueInput {
685 check_name: "fallow/unlisted-binary",
686 description: &format!(
687 "Binary '{}' is used but no installed or listed package provides it",
688 binary.binary_name
689 ),
690 severity: level,
691 category: "Bug Risk",
692 path,
693 begin_line: Some(*line),
694 fingerprint: &fp,
695 },
696 ));
697 }
698 }
699}
700
701fn push_boundary_coverage_issues(
702 issues: &mut Vec<CodeClimateIssue>,
703 violations: &[fallow_types::output_dead_code::BoundaryCoverageViolationFinding],
704 root: &Path,
705 severity: Severity,
706) {
707 if violations.is_empty() {
708 return;
709 }
710 for entry in violations {
711 let level = finding_codeclimate(entry, severity);
712 let v = &entry.violation;
713 let path = cc_path(&v.path, root);
714 let fp = codeclimate_fingerprint_hash(&["fallow/boundary-coverage", &path]);
715 let line = if v.line > 0 { Some(v.line) } else { None };
716 issues.push(dead_code_issue(
717 entry.finding_id.as_deref(),
718 entry.introduced,
719 &[],
720 CodeClimateIssueInput {
721 check_name: "fallow/boundary-coverage",
722 description: &format!("Boundary coverage: {path} matches no configured zone"),
723 severity: level,
724 category: "Bug Risk",
725 path: &path,
726 begin_line: line,
727 fingerprint: &fp,
728 },
729 ));
730 }
731}
732
733fn push_boundary_call_issues(
734 issues: &mut Vec<CodeClimateIssue>,
735 violations: &[fallow_types::output_dead_code::BoundaryCallViolationFinding],
736 root: &Path,
737 severity: Severity,
738) {
739 if violations.is_empty() {
740 return;
741 }
742 for entry in violations {
743 let level = finding_codeclimate(entry, severity);
744 let v = &entry.violation;
745 let path = cc_path(&v.path, root);
746 let fp =
747 codeclimate_fingerprint_hash(&["fallow/boundary-call-violation", &path, &v.callee]);
748 let line = if v.line > 0 { Some(v.line) } else { None };
749 issues.push(dead_code_issue(
750 entry.finding_id.as_deref(),
751 entry.introduced,
752 &[],
753 CodeClimateIssueInput {
754 check_name: "fallow/boundary-call-violation",
755 description: &format!(
756 "Boundary call: `{}` matches forbidden pattern `{}` in zone '{}'",
757 v.callee, v.pattern, v.zone
758 ),
759 severity: level,
760 category: "Bug Risk",
761 path: &path,
762 begin_line: line,
763 fingerprint: &fp,
764 },
765 ));
766 }
767}
768
769fn push_policy_violation_issues(
770 issues: &mut Vec<CodeClimateIssue>,
771 violations: &[fallow_types::output_dead_code::PolicyViolationFinding],
772 root: &Path,
773) {
774 use fallow_types::results::PolicyViolationSeverity;
775
776 for entry in violations {
777 let v = &entry.violation;
778 let path = cc_path(&v.path, root);
779 let rule = format!("{}/{}", v.pack, v.rule_id);
780 let fp =
781 codeclimate_fingerprint_hash(&["fallow/policy-violation", &path, &rule, &v.matched]);
782 let line = if v.line > 0 { Some(v.line) } else { None };
783 let level = severity_to_codeclimate(match v.severity {
787 PolicyViolationSeverity::Error => Severity::Error,
788 PolicyViolationSeverity::Warn => Severity::Warn,
789 });
790 let message = match &v.message {
791 Some(message) => format!(
792 "Policy violation: `{}` is banned by `{rule}`. {message}",
793 v.matched
794 ),
795 None => format!("Policy violation: `{}` is banned by `{rule}`", v.matched),
796 };
797 issues.push(dead_code_issue(
798 entry.finding_id.as_deref(),
799 entry.introduced,
800 &[],
801 CodeClimateIssueInput {
802 check_name: "fallow/policy-violation",
803 description: &message,
804 severity: level,
805 category: "Bug Risk",
806 path: &path,
807 begin_line: line,
808 fingerprint: &fp,
809 },
810 ));
811 }
812}
813
814fn push_invalid_client_export_issues(
815 issues: &mut Vec<CodeClimateIssue>,
816 findings: &[fallow_types::output_dead_code::InvalidClientExportFinding],
817 root: &Path,
818 severity: Severity,
819) {
820 if findings.is_empty() {
821 return;
822 }
823 for entry in findings {
824 let level = finding_codeclimate(entry, severity);
825 let e = &entry.export;
826 let path = cc_path(&e.path, root);
827 let fp =
828 codeclimate_fingerprint_hash(&["fallow/invalid-client-export", &path, &e.export_name]);
829 let line = if e.line > 0 { Some(e.line) } else { None };
830 let message = format!(
831 "Export `{}` is not allowed in a \"{}\" file (Next.js server-only / route-config name)",
832 e.export_name, e.directive
833 );
834 issues.push(dead_code_issue(
835 entry.finding_id.as_deref(),
836 entry.introduced,
837 &[],
838 CodeClimateIssueInput {
839 check_name: "fallow/invalid-client-export",
840 description: &message,
841 severity: level,
842 category: "Bug Risk",
843 path: &path,
844 begin_line: line,
845 fingerprint: &fp,
846 },
847 ));
848 }
849}
850
851fn push_mixed_client_server_barrel_issues(
852 issues: &mut Vec<CodeClimateIssue>,
853 findings: &[fallow_types::output_dead_code::MixedClientServerBarrelFinding],
854 root: &Path,
855 severity: Severity,
856) {
857 if findings.is_empty() {
858 return;
859 }
860 for entry in findings {
861 let level = finding_codeclimate(entry, severity);
862 let b = &entry.barrel;
863 let path = cc_path(&b.path, root);
864 let fp = codeclimate_fingerprint_hash(&[
865 "fallow/mixed-client-server-barrel",
866 &path,
867 &b.client_origin,
868 &b.server_origin,
869 ]);
870 let line = if b.line > 0 { Some(b.line) } else { None };
871 let message = format!(
872 "Barrel re-exports both a \"use client\" module (`{}`) and a server-only module (`{}`); one import drags the other's directive across the boundary",
873 b.client_origin, b.server_origin
874 );
875 issues.push(dead_code_issue(
876 entry.finding_id.as_deref(),
877 entry.introduced,
878 &[],
879 CodeClimateIssueInput {
880 check_name: "fallow/mixed-client-server-barrel",
881 description: &message,
882 severity: level,
883 category: "Bug Risk",
884 path: &path,
885 begin_line: line,
886 fingerprint: &fp,
887 },
888 ));
889 }
890}
891
892fn push_misplaced_directive_issues(
893 issues: &mut Vec<CodeClimateIssue>,
894 findings: &[fallow_types::output_dead_code::MisplacedDirectiveFinding],
895 root: &Path,
896 severity: Severity,
897) {
898 if findings.is_empty() {
899 return;
900 }
901 for entry in findings {
902 let level = finding_codeclimate(entry, severity);
903 let d = &entry.directive_site;
904 let path = cc_path(&d.path, root);
905 let fp = codeclimate_fingerprint_hash(&[
906 "fallow/misplaced-directive",
907 &path,
908 &d.line.to_string(),
909 &d.directive,
910 ]);
911 let line = if d.line > 0 { Some(d.line) } else { None };
912 let message = format!(
913 "Directive `\"{}\"` is not in the leading position, so the RSC bundler ignores it; move it to the top of the file",
914 d.directive
915 );
916 issues.push(dead_code_issue(
917 entry.finding_id.as_deref(),
918 entry.introduced,
919 &[],
920 CodeClimateIssueInput {
921 check_name: "fallow/misplaced-directive",
922 description: &message,
923 severity: level,
924 category: "Bug Risk",
925 path: &path,
926 begin_line: line,
927 fingerprint: &fp,
928 },
929 ));
930 }
931}
932
933fn push_unprovided_inject_issues(
934 issues: &mut Vec<CodeClimateIssue>,
935 findings: &[fallow_types::output_dead_code::UnprovidedInjectFinding],
936 root: &Path,
937 severity: Severity,
938) {
939 if findings.is_empty() {
940 return;
941 }
942 for entry in findings {
943 let level = finding_codeclimate(entry, severity);
944 let i = &entry.inject;
945 let path = cc_path(&i.path, root);
946 let fp = codeclimate_fingerprint_hash(&[
947 "fallow/unprovided-inject",
948 &path,
949 &i.line.to_string(),
950 &i.key_name,
951 ]);
952 let line = if i.line > 0 { Some(i.line) } else { None };
953 let message = format!(
954 "inject(`{}`) has no matching provide(`{}`) in this project; at runtime it returns undefined (provide the key or remove this inject)",
955 i.key_name, i.key_name
956 );
957 issues.push(dead_code_issue(
958 entry.finding_id.as_deref(),
959 entry.introduced,
960 &[],
961 CodeClimateIssueInput {
962 check_name: "fallow/unprovided-inject",
963 description: &message,
964 severity: level,
965 category: "Bug Risk",
966 path: &path,
967 begin_line: line,
968 fingerprint: &fp,
969 },
970 ));
971 }
972}
973
974fn push_unrendered_component_issues(
975 issues: &mut Vec<CodeClimateIssue>,
976 findings: &[fallow_types::output_dead_code::UnrenderedComponentFinding],
977 root: &Path,
978 severity: Severity,
979) {
980 if findings.is_empty() {
981 return;
982 }
983 for entry in findings {
984 let level = finding_codeclimate(entry, severity);
985 let c = &entry.component;
986 let path = cc_path(&c.path, root);
987 let fp = codeclimate_fingerprint_hash(&[
988 "fallow/unrendered-component",
989 &path,
990 &c.line.to_string(),
991 &c.component_name,
992 ]);
993 let line = if c.line > 0 { Some(c.line) } else { None };
994 let message = format!(
995 "component `{}` is reachable but rendered nowhere in this project (render it somewhere or remove it)",
996 c.component_name
997 );
998 issues.push(dead_code_issue(
999 entry.finding_id.as_deref(),
1000 entry.introduced,
1001 &[],
1002 CodeClimateIssueInput {
1003 check_name: "fallow/unrendered-component",
1004 description: &message,
1005 severity: level,
1006 category: "Bug Risk",
1007 path: &path,
1008 begin_line: line,
1009 fingerprint: &fp,
1010 },
1011 ));
1012 }
1013}
1014
1015fn push_unused_component_prop_issues(
1016 issues: &mut Vec<CodeClimateIssue>,
1017 findings: &[fallow_types::output_dead_code::UnusedComponentPropFinding],
1018 root: &Path,
1019 severity: Severity,
1020) {
1021 if findings.is_empty() {
1022 return;
1023 }
1024 for entry in findings {
1025 let level = finding_codeclimate(entry, severity);
1026 let p = &entry.prop;
1027 let path = cc_path(&p.path, root);
1028 let fp = codeclimate_fingerprint_hash(&[
1029 "fallow/unused-component-prop",
1030 &path,
1031 &p.line.to_string(),
1032 &p.prop_name,
1033 ]);
1034 let line = if p.line > 0 { Some(p.line) } else { None };
1035 let message = format!(
1036 "prop `{}` is declared but referenced nowhere in component `{}` (remove it or use it)",
1037 p.prop_name, p.component_name
1038 );
1039 issues.push(dead_code_issue(
1040 entry.finding_id.as_deref(),
1041 entry.introduced,
1042 &[],
1043 CodeClimateIssueInput {
1044 check_name: "fallow/unused-component-prop",
1045 description: &message,
1046 severity: level,
1047 category: "Bug Risk",
1048 path: &path,
1049 begin_line: line,
1050 fingerprint: &fp,
1051 },
1052 ));
1053 }
1054}
1055
1056fn push_unused_component_emit_issues(
1057 issues: &mut Vec<CodeClimateIssue>,
1058 findings: &[fallow_types::output_dead_code::UnusedComponentEmitFinding],
1059 root: &Path,
1060 severity: Severity,
1061) {
1062 if findings.is_empty() {
1063 return;
1064 }
1065 for entry in findings {
1066 let level = finding_codeclimate(entry, severity);
1067 let e = &entry.emit;
1068 let path = cc_path(&e.path, root);
1069 let fp = codeclimate_fingerprint_hash(&[
1070 "fallow/unused-component-emit",
1071 &path,
1072 &e.line.to_string(),
1073 &e.emit_name,
1074 ]);
1075 let line = if e.line > 0 { Some(e.line) } else { None };
1076 let message = format!(
1077 "emit `{}` is declared but emitted nowhere in component `{}` (remove it or emit it)",
1078 e.emit_name, e.component_name
1079 );
1080 issues.push(dead_code_issue(
1081 entry.finding_id.as_deref(),
1082 entry.introduced,
1083 &[],
1084 CodeClimateIssueInput {
1085 check_name: "fallow/unused-component-emit",
1086 description: &message,
1087 severity: level,
1088 category: "Bug Risk",
1089 path: &path,
1090 begin_line: line,
1091 fingerprint: &fp,
1092 },
1093 ));
1094 }
1095}
1096
1097fn push_unused_effect_layer_issues(
1098 issues: &mut Vec<CodeClimateIssue>,
1099 findings: &[fallow_types::output_dead_code::UnusedEffectLayerFinding],
1100 root: &Path,
1101 severity: Severity,
1102) {
1103 for entry in findings {
1104 let level = finding_codeclimate(entry, severity);
1105 let f = &entry.layer;
1106 let path = cc_path(&f.path, root);
1107 let fp = codeclimate_fingerprint_hash(&[
1108 "fallow/unused-effect-layer",
1109 &path,
1110 &f.line.to_string(),
1111 &f.name,
1112 ]);
1113 let line = if f.line > 0 { Some(f.line) } else { None };
1114 let message = format!(
1115 "layer `{}` is composed only into layers that nothing uses ({}); compose it into a live layer or remove it",
1116 f.name,
1117 f.dead_consumers.join(", ")
1118 );
1119 issues.push(dead_code_issue(
1120 entry.finding_id.as_deref(),
1121 entry.introduced,
1122 &[],
1123 CodeClimateIssueInput {
1124 check_name: "fallow/unused-effect-layer",
1125 description: &message,
1126 severity: level,
1127 category: "Bug Risk",
1128 path: &path,
1129 begin_line: line,
1130 fingerprint: &fp,
1131 },
1132 ));
1133 }
1134}
1135
1136fn push_duplicate_export_alias_issues(
1137 issues: &mut Vec<CodeClimateIssue>,
1138 findings: &[fallow_types::output_dead_code::DuplicateExportAliasFinding],
1139 root: &Path,
1140 severity: Severity,
1141) {
1142 for entry in findings {
1143 let level = finding_codeclimate(entry, severity);
1144 let f = &entry.alias;
1145 let path = cc_path(&f.path, root);
1146 let names = f.export_names.join(",");
1147 let fp = codeclimate_fingerprint_hash(&[
1148 "fallow/duplicate-export-alias",
1149 &path,
1150 &f.local_name,
1151 &names,
1152 ]);
1153 let line = if f.line > 0 { Some(f.line) } else { None };
1154 let message = format!(
1155 "`{}` is exported under {} names ({}); keep one name or add the names to ignoreExports",
1156 f.local_name,
1157 f.export_names.len(),
1158 f.export_names.join(", ")
1159 );
1160 issues.push(dead_code_issue(
1161 entry.finding_id.as_deref(),
1162 entry.introduced,
1163 &[],
1164 CodeClimateIssueInput {
1165 check_name: "fallow/duplicate-export-alias",
1166 description: &message,
1167 severity: level,
1168 category: "Duplication",
1169 path: &path,
1170 begin_line: line,
1171 fingerprint: &fp,
1172 },
1173 ));
1174 }
1175}
1176
1177fn push_unused_tagged_error_issues(
1178 issues: &mut Vec<CodeClimateIssue>,
1179 findings: &[fallow_types::output_dead_code::UnusedTaggedErrorFinding],
1180 root: &Path,
1181 severity: Severity,
1182) {
1183 for entry in findings {
1184 let level = finding_codeclimate(entry, severity);
1185 let f = &entry.error;
1186 let path = cc_path(&f.path, root);
1187 let fp = codeclimate_fingerprint_hash(&[
1188 "fallow/unused-tagged-error",
1189 &path,
1190 &f.line.to_string(),
1191 &f.name,
1192 ]);
1193 let line = if f.line > 0 { Some(f.line) } else { None };
1194 let message = format!(
1195 "tagged error `{}` (tag `{}`) is never constructed or failed with; fail with it or remove it",
1196 f.name, f.tag
1197 );
1198 issues.push(dead_code_issue(
1199 entry.finding_id.as_deref(),
1200 entry.introduced,
1201 &[],
1202 CodeClimateIssueInput {
1203 check_name: "fallow/unused-tagged-error",
1204 description: &message,
1205 severity: level,
1206 category: "Bug Risk",
1207 path: &path,
1208 begin_line: line,
1209 fingerprint: &fp,
1210 },
1211 ));
1212 }
1213}
1214
1215fn push_unproduced_catch_tag_issues(
1216 issues: &mut Vec<CodeClimateIssue>,
1217 findings: &[fallow_types::output_dead_code::UnproducedCatchTagFinding],
1218 root: &Path,
1219 severity: Severity,
1220) {
1221 for entry in findings {
1222 let level = finding_codeclimate(entry, severity);
1223 let f = &entry.catch_tag;
1224 let path = cc_path(&f.path, root);
1225 let fp = codeclimate_fingerprint_hash(&[
1226 "fallow/unproduced-catch-tag",
1227 &path,
1228 &f.line.to_string(),
1229 &f.tag,
1230 ]);
1231 let line = if f.line > 0 { Some(f.line) } else { None };
1232 let message = format!(
1233 "catchTag handler for `{}` never runs: no code produces {}",
1234 f.tag,
1235 f.candidate_classes.join(", ")
1236 );
1237 issues.push(dead_code_issue(
1238 entry.finding_id.as_deref(),
1239 entry.introduced,
1240 &[],
1241 CodeClimateIssueInput {
1242 check_name: "fallow/unproduced-catch-tag",
1243 description: &message,
1244 severity: level,
1245 category: "Bug Risk",
1246 path: &path,
1247 begin_line: line,
1248 fingerprint: &fp,
1249 },
1250 ));
1251 }
1252}
1253
1254fn push_unused_server_action_issues(
1255 issues: &mut Vec<CodeClimateIssue>,
1256 findings: &[fallow_types::output_dead_code::UnusedServerActionFinding],
1257 root: &Path,
1258 severity: Severity,
1259) {
1260 if findings.is_empty() {
1261 return;
1262 }
1263 for entry in findings {
1264 let level = finding_codeclimate(entry, severity);
1265 let a = &entry.action;
1266 let path = cc_path(&a.path, root);
1267 let fp = codeclimate_fingerprint_hash(&[
1268 "fallow/unused-server-action",
1269 &path,
1270 &a.line.to_string(),
1271 &a.action_name,
1272 ]);
1273 let line = if a.line > 0 { Some(a.line) } else { None };
1274 let message = format!(
1275 "server action `{}` is exported from a \"use server\" file but no code in this project references it (wire it to a consumer or remove it)",
1276 a.action_name
1277 );
1278 issues.push(dead_code_issue(
1279 entry.finding_id.as_deref(),
1280 entry.introduced,
1281 &[],
1282 CodeClimateIssueInput {
1283 check_name: "fallow/unused-server-action",
1284 description: &message,
1285 severity: level,
1286 category: "Bug Risk",
1287 path: &path,
1288 begin_line: line,
1289 fingerprint: &fp,
1290 },
1291 ));
1292 }
1293}
1294
1295fn push_unused_load_data_key_issues(
1296 issues: &mut Vec<CodeClimateIssue>,
1297 findings: &[fallow_types::output_dead_code::UnusedLoadDataKeyFinding],
1298 root: &Path,
1299 severity: Severity,
1300) {
1301 if findings.is_empty() {
1302 return;
1303 }
1304 for entry in findings {
1305 let level = finding_codeclimate(entry, severity);
1306 let k = &entry.key;
1307 let path = cc_path(&k.path, root);
1308 let fp = codeclimate_fingerprint_hash(&[
1309 "fallow/unused-load-data-key",
1310 &path,
1311 &k.line.to_string(),
1312 &k.key_name,
1313 ]);
1314 let line = if k.line > 0 { Some(k.line) } else { None };
1315 let message = format!(
1316 "load() return key `{}` is read by no consumer (sibling +page.svelte data.<key> or project-wide page.data.<key>); delete the key or wire a consumer",
1317 k.key_name
1318 );
1319 issues.push(dead_code_issue(
1320 entry.finding_id.as_deref(),
1321 entry.introduced,
1322 &[],
1323 CodeClimateIssueInput {
1324 check_name: "fallow/unused-load-data-key",
1325 description: &message,
1326 severity: level,
1327 category: "Bug Risk",
1328 path: &path,
1329 begin_line: line,
1330 fingerprint: &fp,
1331 },
1332 ));
1333 }
1334}
1335
1336fn push_route_collision_issues(
1337 issues: &mut Vec<CodeClimateIssue>,
1338 findings: &[fallow_types::output_dead_code::RouteCollisionFinding],
1339 root: &Path,
1340 severity: Severity,
1341) {
1342 if findings.is_empty() {
1343 return;
1344 }
1345 for entry in findings {
1346 let level = finding_codeclimate(entry, severity);
1347 let c = &entry.collision;
1348 let path = cc_path(&c.path, root);
1349 let fp = codeclimate_fingerprint_hash(&["fallow/route-collision", &path, &c.url]);
1350 let line = if c.line > 0 { Some(c.line) } else { None };
1351 let message = format!(
1352 "Route file resolves to `{}`, also owned by {} other file(s); Next.js fails the build because a URL can have only one owner",
1353 c.url,
1354 c.conflicting_paths.len()
1355 );
1356 issues.push(dead_code_issue(
1357 entry.finding_id.as_deref(),
1358 entry.introduced,
1359 &[],
1360 CodeClimateIssueInput {
1361 check_name: "fallow/route-collision",
1362 description: &message,
1363 severity: level,
1364 category: "Bug Risk",
1365 path: &path,
1366 begin_line: line,
1367 fingerprint: &fp,
1368 },
1369 ));
1370 }
1371}
1372
1373fn push_dynamic_segment_name_conflict_issues(
1374 issues: &mut Vec<CodeClimateIssue>,
1375 findings: &[fallow_types::output_dead_code::DynamicSegmentNameConflictFinding],
1376 root: &Path,
1377 severity: Severity,
1378) {
1379 if findings.is_empty() {
1380 return;
1381 }
1382 for entry in findings {
1383 let level = finding_codeclimate(entry, severity);
1384 let c = &entry.conflict;
1385 let path = cc_path(&c.path, root);
1386 let fp = codeclimate_fingerprint_hash(&[
1387 "fallow/dynamic-segment-name-conflict",
1388 &path,
1389 &c.position,
1390 ]);
1391 let line = if c.line > 0 { Some(c.line) } else { None };
1392 let message = format!(
1393 "Dynamic segments at `{}` use different slug names ({}); Next.js requires one consistent name per dynamic path",
1394 c.position,
1395 c.conflicting_segments.join(", ")
1396 );
1397 issues.push(dead_code_issue(
1398 entry.finding_id.as_deref(),
1399 entry.introduced,
1400 &[],
1401 CodeClimateIssueInput {
1402 check_name: "fallow/dynamic-segment-name-conflict",
1403 description: &message,
1404 severity: level,
1405 category: "Bug Risk",
1406 path: &path,
1407 begin_line: line,
1408 fingerprint: &fp,
1409 },
1410 ));
1411 }
1412}
1413
1414fn push_stale_suppression_issues(
1415 issues: &mut Vec<CodeClimateIssue>,
1416 suppressions: &[fallow_types::results::StaleSuppression],
1417 root: &Path,
1418 rules: &RulesConfig,
1419) {
1420 if suppressions.is_empty() {
1421 return;
1422 }
1423 for s in suppressions {
1424 let severity = if s.missing_reason {
1425 rules.require_suppression_reason
1426 } else {
1427 rules.stale_suppressions
1428 };
1429 let level = finding_codeclimate(s, severity);
1430 let path = cc_path(&s.path, root);
1431 let line_str = s.line.to_string();
1432 let check_name = if s.missing_reason {
1433 "fallow/missing-suppression-reason"
1434 } else {
1435 "fallow/stale-suppression"
1436 };
1437 let fp = codeclimate_fingerprint_hash(&[check_name, &path, &line_str]);
1438 issues.push(dead_code_issue(
1439 s.finding_id.as_deref(),
1440 None,
1442 &[],
1443 CodeClimateIssueInput {
1444 check_name,
1445 description: &s.display_message(),
1446 severity: level,
1447 category: "Bug Risk",
1448 path: &path,
1449 begin_line: Some(s.line),
1450 fingerprint: &fp,
1451 },
1452 ));
1453 }
1454}
1455
1456#[must_use]
1463pub fn build_codeclimate(
1464 results: &AnalysisResults,
1465 root: &Path,
1466 rules: &RulesConfig,
1467) -> Vec<CodeClimateIssue> {
1468 CodeClimateBuilder {
1469 issues: Vec::new(),
1470 results,
1471 root,
1472 rules,
1473 }
1474 .build()
1475}
1476
1477struct CodeClimateBuilder<'a> {
1478 issues: Vec<CodeClimateIssue>,
1479 results: &'a AnalysisResults,
1480 root: &'a Path,
1481 rules: &'a RulesConfig,
1482}
1483
1484impl CodeClimateBuilder<'_> {
1485 fn build(mut self) -> Vec<CodeClimateIssue> {
1486 self.push_file_and_export_issues();
1487 self.push_private_type_leak_issues();
1488 push_deprecated_export_issues(
1489 &mut self.issues,
1490 &self.results.deprecated_exports_in_use,
1491 self.root,
1492 self.rules.deprecated_exports_in_use,
1493 );
1494 self.push_package_dependency_issues();
1495 self.push_type_test_dependency_issues();
1496 self.push_member_issues();
1497 self.push_import_and_duplicate_issues();
1498 self.push_graph_issues();
1499 self.push_boundary_issues();
1500 self.push_suppression_and_catalog_issues();
1501 self.push_override_issues();
1502 self.push_prop_drilling_issues();
1503 self.push_component_shape_issues();
1504 self.issues
1505 }
1506
1507 fn push_file_and_export_issues(&mut self) {
1508 push_unused_file_issues(
1509 &mut self.issues,
1510 &self.results.unused_files,
1511 self.root,
1512 self.rules.unused_files,
1513 );
1514 push_unused_export_issues(UnusedExportIssuesInput {
1515 issues: &mut self.issues,
1516 exports: self.results.unused_exports.iter().map(|e| {
1517 (
1518 &e.export,
1519 e.reachability_caveats.as_slice(),
1520 e.effective_severity,
1521 e.finding_id.as_deref(),
1522 e.introduced,
1523 )
1524 }),
1525 root: self.root,
1526 rule_id: "fallow/unused-export",
1527 direct_label: "Export",
1528 re_export_label: "Re-export",
1529 severity: self.rules.unused_exports,
1530 });
1531 push_unused_export_issues(UnusedExportIssuesInput {
1532 issues: &mut self.issues,
1533 exports: self.results.unused_types.iter().map(|e| {
1534 (
1535 &e.export,
1536 e.reachability_caveats.as_slice(),
1537 e.effective_severity,
1538 e.finding_id.as_deref(),
1539 e.introduced,
1540 )
1541 }),
1542 root: self.root,
1543 rule_id: "fallow/unused-type",
1544 direct_label: "Type export",
1545 re_export_label: "Type re-export",
1546 severity: self.rules.unused_types,
1547 });
1548 }
1549
1550 fn push_private_type_leak_issues(&mut self) {
1551 push_private_type_leak_issues(
1552 &mut self.issues,
1553 &self.results.private_type_leaks,
1554 self.root,
1555 self.rules.private_type_leaks,
1556 );
1557 }
1558
1559 fn push_package_dependency_issues(&mut self) {
1560 push_dep_cc_issues(
1561 &mut self.issues,
1562 self.results.unused_dependencies.iter().map(|f| {
1563 (
1564 &f.dep,
1565 f.reachability_caveats.as_slice(),
1566 f.effective_severity,
1567 f.finding_id.as_deref(),
1568 f.introduced,
1569 )
1570 }),
1571 self.root,
1572 "fallow/unused-dependency",
1573 "dependencies",
1574 self.rules.unused_dependencies,
1575 );
1576 push_dep_cc_issues(
1577 &mut self.issues,
1578 self.results.unused_dev_dependencies.iter().map(|f| {
1579 (
1580 &f.dep,
1581 f.reachability_caveats.as_slice(),
1582 f.effective_severity,
1583 f.finding_id.as_deref(),
1584 f.introduced,
1585 )
1586 }),
1587 self.root,
1588 "fallow/unused-dev-dependency",
1589 "devDependencies",
1590 self.rules.unused_dev_dependencies,
1591 );
1592 push_dep_cc_issues(
1593 &mut self.issues,
1594 self.results.unused_optional_dependencies.iter().map(|f| {
1595 (
1596 &f.dep,
1597 f.reachability_caveats.as_slice(),
1598 f.effective_severity,
1599 f.finding_id.as_deref(),
1600 f.introduced,
1601 )
1602 }),
1603 self.root,
1604 "fallow/unused-optional-dependency",
1605 "optionalDependencies",
1606 self.rules.unused_optional_dependencies,
1607 );
1608 }
1609
1610 fn push_type_test_dependency_issues(&mut self) {
1611 push_type_only_dep_issues(
1612 &mut self.issues,
1613 &self.results.type_only_dependencies,
1614 self.root,
1615 self.rules.type_only_dependencies,
1616 );
1617 push_test_only_dep_issues(
1618 &mut self.issues,
1619 &self.results.test_only_dependencies,
1620 self.root,
1621 self.rules.test_only_dependencies,
1622 );
1623 push_dev_dep_in_prod_issues(
1624 &mut self.issues,
1625 &self.results.dev_dependencies_in_production,
1626 self.root,
1627 self.rules.dev_dependencies_in_production,
1628 );
1629 }
1630
1631 fn push_member_issues(&mut self) {
1632 push_unused_member_issues(
1633 &mut self.issues,
1634 self.results.unused_enum_members.iter().map(|m| {
1635 (
1636 &m.member,
1637 m.reachability_caveats.as_slice(),
1638 m.effective_severity,
1639 m.finding_id.as_deref(),
1640 m.introduced,
1641 )
1642 }),
1643 self.root,
1644 "fallow/unused-enum-member",
1645 "Enum",
1646 self.rules.unused_enum_members,
1647 );
1648 push_unused_member_issues(
1649 &mut self.issues,
1650 self.results.unused_class_members.iter().map(|m| {
1651 (
1652 &m.member,
1653 m.reachability_caveats.as_slice(),
1654 m.effective_severity,
1655 m.finding_id.as_deref(),
1656 m.introduced,
1657 )
1658 }),
1659 self.root,
1660 "fallow/unused-class-member",
1661 "Class",
1662 self.rules.unused_class_members,
1663 );
1664 push_unused_member_issues(
1665 &mut self.issues,
1666 self.results.unused_store_members.iter().map(|m| {
1667 (
1668 &m.member,
1669 m.reachability_caveats.as_slice(),
1670 m.effective_severity,
1671 m.finding_id.as_deref(),
1672 m.introduced,
1673 )
1674 }),
1675 self.root,
1676 "fallow/unused-store-member",
1677 "Store",
1678 self.rules.unused_store_members,
1679 );
1680 push_unused_member_issues(
1681 &mut self.issues,
1682 self.results.unused_namespace_members.iter().map(|m| {
1683 (
1684 &m.member,
1685 m.reachability_caveats.as_slice(),
1686 m.effective_severity,
1687 m.finding_id.as_deref(),
1688 m.introduced,
1689 )
1690 }),
1691 self.root,
1692 "fallow/unused-namespace-member",
1693 "Namespace",
1694 self.rules.unused_namespace_members,
1695 );
1696 push_unused_member_issues(
1697 &mut self.issues,
1698 self.results.unused_protected_class_members.iter().map(|m| {
1699 (
1700 &m.member,
1701 m.reachability_caveats.as_slice(),
1702 m.effective_severity,
1703 m.finding_id.as_deref(),
1704 m.introduced,
1705 )
1706 }),
1707 self.root,
1708 "fallow/unused-protected-class-member",
1709 "Protected class",
1710 self.rules.unused_protected_class_members,
1711 );
1712 namespace_escape::push_namespace_escape_issues(
1713 &mut self.issues,
1714 &self.results.namespace_escapes,
1715 self.root,
1716 self.rules.namespace_escapes,
1717 );
1718 test_only_export::push_test_only_export_issues(
1719 &mut self.issues,
1720 &self.results.test_only_exports,
1721 self.root,
1722 self.rules.test_only_exports,
1723 );
1724 }
1725
1726 fn push_import_and_duplicate_issues(&mut self) {
1727 push_unresolved_import_issues(
1728 &mut self.issues,
1729 &self.results.unresolved_imports,
1730 self.root,
1731 self.rules.unresolved_imports,
1732 );
1733 push_unlisted_dep_issues(
1734 &mut self.issues,
1735 &self.results.unlisted_dependencies,
1736 self.root,
1737 self.rules.unlisted_dependencies,
1738 );
1739 push_unlisted_binary_issues(
1740 &mut self.issues,
1741 &self.results.unlisted_binaries,
1742 self.root,
1743 self.rules.unlisted_binaries,
1744 );
1745 push_duplicate_export_issues(
1746 &mut self.issues,
1747 &self.results.duplicate_exports,
1748 self.root,
1749 self.rules.duplicate_exports,
1750 );
1751 }
1752
1753 fn push_graph_issues(&mut self) {
1754 push_circular_dep_issues(
1755 &mut self.issues,
1756 &self.results.circular_dependencies,
1757 self.root,
1758 self.rules.circular_dependencies,
1759 );
1760 push_re_export_cycle_issues(
1761 &mut self.issues,
1762 &self.results.re_export_cycles,
1763 self.root,
1764 self.rules.re_export_cycle,
1765 );
1766 push_package_cycle_issues(
1767 &mut self.issues,
1768 &self.results.package_cycles,
1769 self.root,
1770 self.rules.package_cycle,
1771 );
1772 }
1773
1774 fn push_boundary_issues(&mut self) {
1775 self.push_architecture_boundary_issues();
1776 self.push_client_server_boundary_issues();
1777 self.push_component_boundary_issues();
1778 self.push_framework_route_issues();
1779 }
1780
1781 fn push_architecture_boundary_issues(&mut self) {
1782 push_boundary_violation_issues(
1783 &mut self.issues,
1784 &self.results.boundary_violations,
1785 self.root,
1786 self.rules.boundary_violation,
1787 );
1788 push_boundary_coverage_issues(
1789 &mut self.issues,
1790 &self.results.boundary_coverage_violations,
1791 self.root,
1792 self.rules.boundary_violation,
1793 );
1794 push_boundary_call_issues(
1795 &mut self.issues,
1796 &self.results.boundary_call_violations,
1797 self.root,
1798 self.rules.boundary_violation,
1799 );
1800 push_policy_violation_issues(&mut self.issues, &self.results.policy_violations, self.root);
1801 }
1802
1803 fn push_client_server_boundary_issues(&mut self) {
1804 push_invalid_client_export_issues(
1805 &mut self.issues,
1806 &self.results.invalid_client_exports,
1807 self.root,
1808 self.rules.invalid_client_export,
1809 );
1810 push_mixed_client_server_barrel_issues(
1811 &mut self.issues,
1812 &self.results.mixed_client_server_barrels,
1813 self.root,
1814 self.rules.mixed_client_server_barrel,
1815 );
1816 push_misplaced_directive_issues(
1817 &mut self.issues,
1818 &self.results.misplaced_directives,
1819 self.root,
1820 self.rules.misplaced_directive,
1821 );
1822 }
1823
1824 fn push_component_boundary_issues(&mut self) {
1825 push_unprovided_inject_issues(
1826 &mut self.issues,
1827 &self.results.unprovided_injects,
1828 self.root,
1829 self.rules.unprovided_injects,
1830 );
1831 push_unrendered_component_issues(
1832 &mut self.issues,
1833 &self.results.unrendered_components,
1834 self.root,
1835 self.rules.unrendered_components,
1836 );
1837 push_absent_component_prop_issues(
1838 &mut self.issues,
1839 &self.results.absent_component_props,
1840 self.root,
1841 self.rules.absent_component_props,
1842 );
1843 push_constant_parameter_issues(
1844 &mut self.issues,
1845 &self.results.constant_parameters,
1846 self.root,
1847 self.rules.constant_parameters,
1848 );
1849 push_unused_component_prop_issues(
1850 &mut self.issues,
1851 &self.results.unused_component_props,
1852 self.root,
1853 self.rules.unused_component_props,
1854 );
1855 push_unused_component_emit_issues(
1856 &mut self.issues,
1857 &self.results.unused_component_emits,
1858 self.root,
1859 self.rules.unused_component_emits,
1860 );
1861 push_unused_component_input_issues(
1862 &mut self.issues,
1863 &self.results.unused_component_inputs,
1864 self.root,
1865 self.rules.unused_component_inputs,
1866 );
1867 push_unused_component_output_issues(
1868 &mut self.issues,
1869 &self.results.unused_component_outputs,
1870 self.root,
1871 self.rules.unused_component_outputs,
1872 );
1873 push_unused_svelte_event_issues(
1874 &mut self.issues,
1875 &self.results.unused_svelte_events,
1876 self.root,
1877 self.rules.unused_svelte_events,
1878 );
1879 push_unused_effect_layer_issues(
1880 &mut self.issues,
1881 &self.results.unused_effect_layers,
1882 self.root,
1883 self.rules.unused_effect_layers,
1884 );
1885 push_duplicate_export_alias_issues(
1886 &mut self.issues,
1887 &self.results.duplicate_export_aliases,
1888 self.root,
1889 self.rules.duplicate_export_aliases,
1890 );
1891 push_unused_tagged_error_issues(
1892 &mut self.issues,
1893 &self.results.unused_tagged_errors,
1894 self.root,
1895 self.rules.unused_tagged_errors,
1896 );
1897 push_unproduced_catch_tag_issues(
1898 &mut self.issues,
1899 &self.results.unproduced_catch_tags,
1900 self.root,
1901 self.rules.unproduced_catch_tags,
1902 );
1903 }
1904
1905 fn push_framework_route_issues(&mut self) {
1906 push_unused_server_action_issues(
1907 &mut self.issues,
1908 &self.results.unused_server_actions,
1909 self.root,
1910 self.rules.unused_server_actions,
1911 );
1912 push_unused_load_data_key_issues(
1913 &mut self.issues,
1914 &self.results.unused_load_data_keys,
1915 self.root,
1916 self.rules.unused_load_data_keys,
1917 );
1918 push_route_collision_issues(
1919 &mut self.issues,
1920 &self.results.route_collisions,
1921 self.root,
1922 self.rules.route_collision,
1923 );
1924 push_dynamic_segment_name_conflict_issues(
1925 &mut self.issues,
1926 &self.results.dynamic_segment_name_conflicts,
1927 self.root,
1928 self.rules.dynamic_segment_name_conflict,
1929 );
1930 }
1931
1932 fn push_suppression_and_catalog_issues(&mut self) {
1933 push_stale_suppression_issues(
1934 &mut self.issues,
1935 &self.results.stale_suppressions,
1936 self.root,
1937 self.rules,
1938 );
1939 push_unused_catalog_entry_issues(
1940 &mut self.issues,
1941 &self.results.unused_catalog_entries,
1942 self.root,
1943 self.rules.unused_catalog_entries,
1944 );
1945 push_empty_catalog_group_issues(
1946 &mut self.issues,
1947 &self.results.empty_catalog_groups,
1948 self.root,
1949 self.rules.empty_catalog_groups,
1950 );
1951 push_unresolved_catalog_reference_issues(
1952 &mut self.issues,
1953 &self.results.unresolved_catalog_references,
1954 self.root,
1955 self.rules.unresolved_catalog_references,
1956 );
1957 }
1958
1959 fn push_override_issues(&mut self) {
1960 push_unused_dependency_override_issues(
1961 &mut self.issues,
1962 &self.results.unused_dependency_overrides,
1963 self.root,
1964 self.rules.unused_dependency_overrides,
1965 );
1966 push_misconfigured_dependency_override_issues(
1967 &mut self.issues,
1968 &self.results.misconfigured_dependency_overrides,
1969 self.root,
1970 self.rules.misconfigured_dependency_overrides,
1971 );
1972 }
1973}
1974
1975#[path = "dead_code_codeclimate_duplicates.rs"]
1976mod dead_code_codeclimate_duplicates;
1977use dead_code_codeclimate_duplicates::push_duplicate_export_issues;
1978
1979#[path = "dead_code_codeclimate_boundary.rs"]
1980mod boundary_render;
1981use boundary_render::push_boundary_violation_issues;
1982
1983#[path = "dead_code_codeclimate_cycles.rs"]
1984mod cycles;
1985use cycles::{push_circular_dep_issues, push_package_cycle_issues, push_re_export_cycle_issues};
1986
1987#[cfg(test)]
1988#[path = "dead_code_codeclimate_tests.rs"]
1989mod tests;