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

Explicit Enum Raw Value Rule #1788

Merged
merged 12 commits into from
Aug 26, 2017
Merged

Explicit Enum Raw Value Rule #1788

merged 12 commits into from
Aug 26, 2017

Conversation

Mazyod
Copy link
Contributor

@Mazyod Mazyod commented Aug 19, 2017

Hey, as @marcelofabri suggested, this was a good rule for new contributors to get their hands dirty (assuming I did this with reasonable correctness!).

I feel the PR is self-explanatory, but just to reiterate:

  1. Followed the contributing guideline points (except linux tests, will test on linux now)
  2. The rule is opt-in, and enforces the existence of init_expr
  3. Tested enums with associated types, Int enums, and String enums.

Fixes #1778

@SwiftLintBot
Copy link

SwiftLintBot commented Aug 19, 2017

338 Warnings
⚠️ Make sure that the docs are updated by running the Generate docs scheme.
⚠️ This PR introduced a violation in Alamofire: /Example/Source/DetailViewController.swift#L30:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Alamofire: /Example/Source/DetailViewController.swift#L30:23: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/SearchViewController.swift#L15:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/SearchViewController.swift#L16:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/ContentBlocker/ContentBlockerHelper.swift#L23:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/ContentBlocker/ContentBlockerHelper.swift#L24:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/ContentBlocker/ContentBlockerHelper.swift#L25:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/ContentBlocker/ContentBlockerHelper.swift#L43:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/ContentBlocker/ContentBlockerHelper.swift#L44:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/ActivityStreamPanel.swift#L161:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/ActivityStreamPanel.swift#L162:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/ActivityStreamPanel.swift#L163:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/ActivityStreamPanel.swift#L164:14: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/BookmarkPayload.swift#L52:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/BookmarkPayload.swift#L53:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/BookmarkPayload.swift#L54:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/BookmarkPayload.swift#L55:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/BookmarkPayload.swift#L56:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/BookmarkPayload.swift#L57:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/Synchronizers/Downloader.swift#L227:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/Synchronizers/Downloader.swift#L228:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/Synchronizers/Downloader.swift#L229:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Firefox: /Sync/Synchronizers/Downloader.swift#L230:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/BackerDashboardProjectsDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/BackerDashboardProjectsDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ActivitiesDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ActivitiesDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ActivitiesDataSource.swift#L10:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ActivitiesDataSource.swift#L11:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/CommentsDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/CommentsDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DashboardDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DashboardDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DashboardDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DashboardDataSource.swift#L10:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DashboardDataSource.swift#L11:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DashboardDataSource.swift#L12:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryFiltersDataSource.swift#L6:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryFiltersDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryFiltersDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryFiltersDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryFiltersDataSource.swift#L10:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryFiltersDataSource.swift#L11:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryFiltersDataSource.swift#L12:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/FindFriendsDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/FindFriendsDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/FindFriendsDataSource.swift#L10:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryProjectsDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryProjectsDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/DiscoveryProjectsDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/LiveStreamChatDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/MessagesDataSource.swift#L6:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/MessagesDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/MessagesDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/MessagesDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/MessageThreadsDataSource.swift#L6:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/MessageThreadsDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProfileDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectActivitiesDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectActivitiesDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/SearchDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/SearchDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/SearchDataSource.swift#L10:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectPamphletContentDataSource.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectPamphletContentDataSource.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectPamphletContentDataSource.swift#L10:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectPamphletContentDataSource.swift#L11:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectPamphletContentDataSource.swift#L12:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/ProjectPamphletContentDataSource.swift#L13:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/SearchMessagesDataSource.swift#L6:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/DataSources/SearchMessagesDataSource.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Nib.swift#L4:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Nib.swift#L5:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Nib.swift#L6:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Nib.swift#L7:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L4:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L5:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L6:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L7:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L8:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L9:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L10:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L11:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L12:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L13:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L14:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L15:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L16:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L17:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L18:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L19:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L20:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L21:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L22:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L23:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L24:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L25:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L26:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L27:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L28:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L29:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L30:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L31:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L32:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/Library/Storyboard.swift#L33:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/lib/Method.swift#L2:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/lib/Method.swift#L3:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/lib/Method.swift#L4:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/lib/Method.swift#L5:8: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Backing.swift#L21:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Backing.swift#L22:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Backing.swift#L23:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Backing.swift#L24:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Backing.swift#L25:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Backing.swift#L26:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/lib/Route.swift#L71:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/lib/Route.swift#L72:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/CheckoutEnvelope.swift#L7:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/CheckoutEnvelope.swift#L8:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/CheckoutEnvelope.swift#L9:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/CheckoutEnvelope.swift#L10:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/DiscoveryParams.swift#L27:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/DiscoveryParams.swift#L28:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/DiscoveryParams.swift#L29:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/DiscoveryParams.swift#L34:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/DiscoveryParams.swift#L36:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Project.swift#L40:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Project.swift#L41:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Project.swift#L42:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Project.swift#L43:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ This PR introduced a violation in Kickstarter: /KsApi/models/Project.swift#L44:10: warning: Explicit Enum Raw Value Violation: Enums should be explicitly assigned their raw values. (explicit_enum_raw_value)
⚠️ Danger found 338 violations with this PR. Due to GitHub's max issue comment size, the number shown has been truncated to 132.
12 Messages
📖 Linting Aerial with this PR took 0.37s vs 0.34s on master (8% slower)
📖 Linting Alamofire with this PR took 2.37s vs 2.46s on master (3% faster)
📖 Linting Firefox with this PR took 10.07s vs 10.52s on master (4% faster)
📖 Linting Kickstarter with this PR took 16.19s vs 16.28s on master (0% faster)
📖 Linting Moya with this PR took 1.07s vs 1.07s on master (0% slower)
📖 Linting Nimble with this PR took 1.42s vs 1.44s on master (1% faster)
📖 Linting Quick with this PR took 0.47s vs 0.46s on master (2% slower)
📖 Linting Realm with this PR took 2.28s vs 2.28s on master (0% slower)
📖 Linting SourceKitten with this PR took 0.87s vs 0.86s on master (1% slower)
📖 Linting Sourcery with this PR took 3.78s vs 3.81s on master (0% faster)
📖 Linting Swift with this PR took 10.43s vs 10.4s on master (0% slower)
📖 Linting WordPress with this PR took 9.57s vs 9.56s on master (0% slower)

Generated by 🚫 Danger


let locs = substructureElements(of: dictionary, matching: .enumcase)
.flatMap { substructureElements(of: $0, matching: .enumelement) }
.flatMap(enumElementsMissingInitExpr(_:))
Copy link
Contributor

Choose a reason for hiding this comment

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

You can safely remove the (_:) here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

very cool! Thanks

private func substructureElements(of dict: [String: SourceKitRepresentable],
matching kind: SwiftDeclarationKind) -> [[String: SourceKitRepresentable]] {
return dict.substructure
.filter { $0.kind.flatMap(SwiftDeclarationKind.init(rawValue:)) == kind }
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here for (rawValue:)

Copy link
Collaborator

@marcelofabri marcelofabri left a comment

Choose a reason for hiding this comment

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

This looks great, I've just made some comments. Thanks for your contribution!

public init() {}

public static let description = RuleDescription(
identifier: "explicit_associated_enum_value",
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not a good name, because when talking about enums, associated values are generally referred to cases with "parameters". Instead, we should use "raw values"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought those were associated types, since jpsim called them associated values. But sure, I don't have any attachments to the name :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

}

// Check if it's an associated value enum
guard !dictionary.inheritedTypes.isEmpty else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not enough, because enums can implement protocols, for example:

protocol Foo {}
enum Bar: Foo {
  case bar
}

Instead, we should keep a list of possible raw types that support implicit raw values. As far as I know, that means String and all numeric types (Int, Float, Int64, ...). Types like Character conform to RawRepresentable, but they need an explicit value.

}
}

private func violatingOffsetsForEnum(dictionary: [String: SourceKitRepresentable], file: File) -> [Int] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you don't actually use the file parameter here

@Mazyod
Copy link
Contributor Author

Mazyod commented Aug 26, 2017

@Mazyod
Copy link
Contributor Author

Mazyod commented Aug 26, 2017

After reading more on CodingKey, I think we will only need to check against CodingKey conformance to trigger this warning in Swift 4.

@Mazyod Mazyod changed the title Explicit Associated Enum Value Rule Explicit Enum Raw Value Rule Aug 26, 2017
@codecov-io
Copy link

codecov-io commented Aug 26, 2017

Codecov Report

Merging #1788 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1788      +/-   ##
==========================================
+ Coverage   88.17%   88.21%   +0.04%     
==========================================
  Files         223      224       +1     
  Lines       11027    11068      +41     
==========================================
+ Hits         9723     9764      +41     
  Misses       1304     1304
Impacted Files Coverage Δ
Tests/SwiftLintFrameworkTests/RulesTests.swift 100% <100%> (ø) ⬆️
...LintFramework/Rules/ExplicitEnumRawValueRule.swift 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a71e792...6e6ae83. Read the comment docs.

Int.self, Int8.self, Int16.self, Int32.self, Int64.self,
UInt.self, UInt8.self, UInt16.self, UInt32.self, UInt64.self,
Double.self, Float.self, Float80.self, Decimal.self, NSNumber.self,
NSDecimalNumber.self, "NSInteger", String.self
Copy link
Collaborator

Choose a reason for hiding this comment

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

TIL that you can use NSNumber and other types as raw values 😅

@marcelofabri
Copy link
Collaborator

I guess we should add CodingKey to that list?

I don't think so, because to add an explicit value, you still need to "inherit" from a raw value type.

@marcelofabri marcelofabri merged commit d9c5565 into realm:master Aug 26, 2017

private func violatingOffsetsForEnum(dictionary: [String: SourceKitRepresentable]) -> [Int] {

let locs = substructureElements(of: dictionary, matching: .enumcase)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you please combine the 3 flatMaps? I'd also recommend not storing the result in an intermediate variable, since it's unused other than just being returned right away, so doesn't make things any clearer IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I can see this logic using a single loop with guards and continue

Copy link
Collaborator

Choose a reason for hiding this comment

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

Nevermind, I don't think my suggestion would improve things after all.

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.

6 participants