Commit Graph
14 Commits
Author SHA1 Message Date
Cursor AgentandRobert C. Martin 2862b8428e Compare a deinit the way other Swift methods are compared.
A deinit has a body, and a function nested inside it was being reported
on its own. The deinit is now the candidate, and the nested function
stays inside it. Actor methods are documented with the other type methods.

Proved by test_a_deinit_is_compared_and_keeps_its_nested_function.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:51:01 +00:00
Cursor AgentandRobert C. Martin 105ff6f50c Keep the label on a Swift trailing closure.
The grammar puts that label on the call as an identifier, so label:
and action: scored 1.0. The spelling now stays, as a parenthesized
argument label does. A closure body still drops its locals.

Proved by test_a_trailing_closure_label_is_part_of_the_call.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:49:45 +00:00
Cursor AgentandRobert C. Martin 121fb2f4ba Keep Swift range operators in the fingerprint.
..< and ... were dropped as punctuation, so a half-open range and a
closed range scored 1.0. They now stay, as >= and != do.

Proved by test_a_different_swift_range_lowers_the_score. The suite
is 93 passed.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:49:25 +00:00
Cursor AgentandRobert C. Martin 1bb1936ad5 Document Swift as a supported language.
The scan already reports Swift pairs in the text report and in
.metrics/dry.edn. The help text, the language table, and the project
description still listed the previous six languages.

Proved: test_help_does_not_scan failed until the help named
Swift (.swift) and *Tests.swift, then passed. test_swift_report_writes_the_same_snapshot
checks the text lines and :language \"swift\" in dry.edn. The shared
language tests now include Swift. 92 tests passed.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:35:40 +00:00
Cursor AgentandRobert C. Martin f667ad03ba Skip Swift test files the way the other languages skip theirs.
A Swift package keeps tests in Tests/ and names them *Tests.swift.
Both were scanned as production code, so test helpers showed up as
duplicate candidates.

The suffix checks were one list already in spirit. Tests.swift joins
that list, and Tests joins the skipped directories. Folding the old
suffix branches into the list keeps the decision in one place.

Proved: test_a_swift_package_skips_its_tests failed while reporting
Sources/HiddenTests.swift and Tests/AppTests.swift, then passed with
only Sources/App.swift. The existing test-name suite still passed.
91 tests.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:35:40 +00:00
Cursor AgentandRobert C. Martin ae38087644 Select Swift methods, view bodies, and top-level closures.
A SwiftUI body is a computed property, a protocol requirement has no
body, and a closure or local function belongs to the form around it.
The first picker kept every function, including the nested ones, and
missed the body, the protocol default, and a file-level closure.

Proved: test_swift_keeps_methods_bodies_and_top_level_closures_only
failed by reporting the nested function at lines 7-9. The SwiftUI pair
and the top-level closure pair were empty. All three pass, including a
Text versus Label view that scores below 1.0. The full suite passed,
90 tests, and dryer reports no duplication at 0.8.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:35:40 +00:00
Cursor AgentandRobert C. Martin 41384b723d Normalize Swift members, operators, labels, and literals.
Call names were kept, and everything else in a Swift expression was
still a generic word. filter matched select, >= matched !=, an
argument label disappeared, and a string did not match a number.

A navigation_expression is an attribute, so the called member stays
and the field name does not. A custom operator and an argument label
keep their spelling. Swift strings, nil, and real numbers are
literals, an interpolation is not, and a block comment is skipped.

Proved: the Swift tests for methods, operators, labels, literals,
comments, and tuple indexes pass, and the other languages still pass.
92 tests.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:35:40 +00:00
Cursor AgentandRobert C. Martin 16b5db55b2 Keep Swift call names so a different callee scores lower.
Renamed locals already matched, and so did filter versus select,
because a Swift call keeps its name in a call_suffix and the name
is a simple_identifier. Both were treated as ordinary words, so the
callee disappeared and the score stayed 1.0.

simple_identifier is a name, and call_suffix is the argument list, the
same two decisions the other languages already make.

Proved: test_a_different_swift_callee_is_not_the_same_structure failed
on a score of 1.0, then passed with the pair below 1.0. The renamed-local
pair still scores 1.0. The full suite passed, 82 tests.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:28:45 +00:00
Cursor AgentandRobert C. Martin a37f7d1827 Compare Swift functions so renamed locals still match.
A .swift file was not a source file, so a scan reported no candidates.
.swift now selects the swift grammar, and a function with a body is a
candidate form.

Proved: test_renamed_locals_in_swift_functions_match failed with an empty
report, then passed with one swift pair at score 1.0. The full suite
passed, 81 tests.

Co-authored-by: Robert C. Martin <[email protected]>
2026-11-25 23:28:19 +00:00
Robert C. Martin 66ff6d21a4 Bring every CRAP score under 10 except the option parser.
The reader, the normalizer, the TypeScript picker, and the fingerprint printer are each a small function. parse_args stays the option switch.
2026-10-03 18:03:53 -05:00
Robert C. Martin 2be6acadf5 Fail closed on git status and walk deep forms without recursion.
Status records are NUL-terminated, and a git failure returns git's status. .test.cts and .spec.cts are tests. Help lists every skipped directory.
2026-10-03 17:48:35 -05:00
Robert C. Martin c726bf0158 Add the Zero-Clause BSD license. 2026-10-03 08:48:27 -05:00
Robert C. Martin 6892667b34 Extract helpers and test the behavior mutation testing was missing.
The switches stay intact. The new tests pin option parsing, file selection, normalization, and which forms each language compares, so the survivors that remain are equivalent mutants.
2026-09-30 17:25:34 -05:00
Robert C. Martin fcf865759d Add a multi-language duplicate finder that writes .metrics/dry.edn. 2026-09-30 14:37:25 -05:00