Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back void_function_in_ternary rule #3956

Merged
merged 5 commits into from
Jun 27, 2022

Conversation

marcelofabri
Copy link
Collaborator

No description provided.

@SwiftLintBot
Copy link

SwiftLintBot commented Apr 17, 2022

34 Warnings
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/SharedFunctions.swift:59:17: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in Kickstarter: /Library/Tracking/KSRAnalyticsTests.swift:1920:14: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in Kickstarter: /Library/Tracking/KSRAnalyticsTests.swift:1923:18: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Activity/BaseActivityListViewController.swift:220:38: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Activity/BaseActivityListViewController.swift:223:39: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Blog/Blog Details/Detail Header/BlogDetailHeaderView.swift:68:19: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:1017:31: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:674:35: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:677:35: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:755:31: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:770:31: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:785:31: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:798:31: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Comments/CommentDetailViewController.swift:942:44: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Gutenberg/Utils/GutenbergStockPhotos.swift:40:27: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Gutenberg/Utils/GutenbergTenorMediaPicker.swift:39:27: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Likes/LikesListController.swift:53:34: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Notifications/Views/NoteBlockUserTableViewCell.swift:97:20: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PrepublishingViewController.swift:328:40: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/Comments/ReaderCommentsViewController.swift:262:39: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift:332:62: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailCoordinator.swift:349:62: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/Detail/Views/ReaderDetailCommentsHeader.swift:129:30: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Stats/Referrer Details/ReferrerDetailsSpamActionCell.swift:23:19: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Stats/Shared Views/TopTotalsCell.swift:325:22: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Themes/ThemeBrowserViewController.swift:625:30: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressAllTimeWidget/AllTimeViewController.swift:123:59: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressAllTimeWidget/AllTimeViewController.swift:354:23: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressTest/FollowCommentsServiceTests.swift:148:53: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressTest/ReaderSelectInterestsCoordinatorTests.swift:108:28: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressThisWeekWidget/ThisWeekViewController.swift:123:53: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressThisWeekWidget/ThisWeekViewController.swift:358:23: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressTodayWidget/TodayViewController.swift:123:59: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
⚠️ This PR introduced a violation in WordPress: /WordPress/WordPressTodayWidget/TodayViewController.swift:354:23: warning: Void Function in Ternary Violation: Using ternary to call Void functions should be avoided. (void_function_in_ternary)
12 Messages
📖 Linting Aerial with this PR took 1.01s vs 0.99s on master (2% slower)
📖 Linting Alamofire with this PR took 1.1s vs 1.08s on master (1% slower)
📖 Linting Firefox with this PR took 4.38s vs 4.29s on master (2% slower)
📖 Linting Kickstarter with this PR took 7.57s vs 7.55s on master (0% slower)
📖 Linting Moya with this PR took 0.52s vs 0.56s on master (7% faster)
📖 Linting Nimble with this PR took 0.41s vs 0.41s on master (0% slower)
📖 Linting Quick with this PR took 0.19s vs 0.18s on master (5% slower)
📖 Linting Realm with this PR took 10.21s vs 10.2s on master (0% slower)
📖 Linting SourceKitten with this PR took 0.34s vs 0.34s on master (0% slower)
📖 Linting Sourcery with this PR took 2.03s vs 2.03s on master (0% slower)
📖 Linting Swift with this PR took 3.43s vs 3.42s on master (0% slower)
📖 Linting WordPress with this PR took 8.12s vs 8.1s on master (0% slower)

Generated by 🚫 Danger

@codecov-commenter
Copy link

Codecov Report

Merging #3956 (0e502a3) into master (a786e31) will decrease coverage by 0.00%.
The diff coverage is 88.23%.

@@            Coverage Diff             @@
##           master    #3956      +/-   ##
==========================================
- Coverage   92.58%   92.58%   -0.01%     
==========================================
  Files         442      443       +1     
  Lines       22271    22305      +34     
==========================================
+ Hits        20620    20650      +30     
- Misses       1651     1655       +4     
Impacted Files Coverage Δ
...Idiomatic/VoidFunctionInTernaryConditionRule.swift 87.50% <87.50%> (ø)
...tFrameworkTests/AutomaticRuleTests.generated.swift 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following code causes a violation in the last function body while it shouldn't:

func get() -> Int { 1 }
func get(from elements: [Int]) -> Int { elements[0] }
func f(elements: [Int]) -> Int { elements.isEmpty ? get() : get(from: elements) }

@marcelofabri
Copy link
Collaborator Author

The following code causes a violation in the last function body while it shouldn't:

func get() -> Int { 1 }
func get(from elements: [Int]) -> Int { elements[0] }
func f(elements: [Int]) -> Int { elements.isEmpty ? get() : get(from: elements) }

nice catch!

@marcelofabri marcelofabri force-pushed the marcelo/void_function_in_ternary-again branch from 0e502a3 to 9bdacab Compare May 9, 2022 02:38
Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@marcelofabri marcelofabri force-pushed the marcelo/void_function_in_ternary-again branch from 9bdacab to 14c07d3 Compare June 27, 2022 08:23
@marcelofabri marcelofabri merged commit 45a03de into master Jun 27, 2022
@marcelofabri marcelofabri deleted the marcelo/void_function_in_ternary-again branch June 27, 2022 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants