Skip to content

Commit

Permalink
[Danger Rules] Documentation for #11280 (#367)
Browse files Browse the repository at this point in the history
* [Danger Rules] Documentation for #11280

Doc for https://github.com/babylonhealth/babylon-ios/pull/11280

* typo

* Typo

Co-Authored-By: João Pereira <[email protected]>

Co-authored-by: João Pereira <[email protected]>
  • Loading branch information
Olivier Halligon and João Pereira authored Apr 3, 2020
1 parent 5722c1b commit aee0eae
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Cookbook/Technical-Documents/DangerRules.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,21 @@ This rule will warn you if any part of the pbxproj references an UUID that got a

When that happens, you need to figure out if the removal of the file was intended as part of your PR (and if so, fix the merge by also removing the lines pointing to that now-deleted file reference), or if the removal of the file from the pbxproj was unintented (and if so, restore it). You could do that by editing the `pbxproj` manually, but if possible it's even better if you can fix it in Xcode (e.g. by removing the offending file from the project and add it again)

## Detect Missing Feedbacks

> * Declared in: `danger-ci/feedbacks.rb`
> * Function: `check_feedbacks_in_viewmodels`
> * Type: ⚠️ warning
This rule analyses any `*ViewModel.swift` file created or modified in the PR, and try to determine if any `Feedback` static method was declared but not called.
This is typically to catch cases when you declare a new `Feedback` in your code but forgot to then add it to the state machine.

This rule uses `sourcekitten` to dump the structure of the Swift code. It uses it to finds all the `static func` returning a `Feedback` declared in your code, then searches for all the method calls in your code to see if that list contains calls to all the `Feedback` methods declared. If it finds a `static func … -> Feedback<…>` method that is never called, it emits a warning.

Note that this rule can have false positives in rare cases. Especially if you use constructs like `obj.map(Self.whenBlah)`, it doesn't detect `whenBlah` as a method call because it is encapsulated inside a `map`. This is why this rule is only a warning.

(It still detects `Feedbacks` called conditionally though – like `if (cond) { feedbacks += Self.whenBlah() }` – and should still catch the most common cases of forgetting to add a newly-created `Feedback` to the state machine)

## swiftlint

> * Declared in: `danger-ci/swiftlint.rb`
Expand Down

0 comments on commit aee0eae

Please sign in to comment.