Skip to content
New issue

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

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

Already on GitHub? # to your account

Added fileprivateRule #1489

Closed
wants to merge 1 commit into from

Conversation

masters3d
Copy link
Contributor

@masters3d masters3d commented May 3, 2017

Added fileprivateRule to check for top-level usages of fileprivate and recommend private instead. This is inline with SE-0169's goal "for fileprivate to be used rarely". There is a also an "strict" option that will mark every fileprivate as a violation.
closes #1469

benchmark

0.001: custom_rules
0.001: file_length
0.001: leading_whitespace
0.003: trailing_newline
0.021: redundant_discardable_let
0.022: force_try
0.023: todo
0.024: shorthand_operator
0.026: return_arrow_whitespace
0.027: syntactic_sugar
0.027: force_cast
0.032: closing_brace
0.033: void_return
0.035: empty_parameters
0.035: legacy_constructor
0.035: statement_position
0.036: file_header
0.039: nimble_operator
0.042: trailing_semicolon
0.043: trailing_whitespace
0.044: legacy_cggeometry_functions
0.045: implicit_getter
0.046: operator_whitespace
0.051: legacy_nsgeometry_functions
0.054: sorted_imports
0.056: legacy_constant
0.057: fileprivate           <------------------------------------------------
0.060: first_where
0.064: redundant_nil_coalescing
0.077: empty_count
0.097: control_statement
0.115: vertical_whitespace
0.170: opening_brace
0.197: number_separator
0.279: for_where
0.283: unused_enumerated
0.299: mark
0.301: operator_usage_whitespace
0.305: class_delegate_protocol
0.307: comma
0.309: redundant_string_enum_value
0.314: valid_ibinspectable
0.317: private_unit_test
0.319: weak_delegate
0.320: private_outlet
0.329: overridden_super_call
0.330: prohibited_super_call
0.352: dynamic_inline
0.353: notification_center_detachment
0.365: redundant_optional_initialization
0.380: discarded_notification_center_observer
0.382: fatal_error_message
0.398: type_name
0.405: type_body_length
0.426: attributes
0.428: explicit_init
0.458: compiler_protocol_init
0.462: function_parameter_count
0.499: identifier_name
0.514: cyclomatic_complexity
0.516: unused_optional_binding
0.517: vertical_parameter_alignment
0.517: nesting
0.533: object_literal
0.546: function_body_length
0.554: generic_type_name
0.586: closure_parameter_position
0.593: trailing_comma
0.599: large_tuple
0.634: colon
0.683: redundant_void_return
0.722: unused_closure_parameter
0.738: closure_spacing
0.752: line_length
0.804: empty_parentheses_with_trailing_closure
0.932: closure_end_indentation

@SwiftLintBot
Copy link

SwiftLintBot commented May 3, 2017

100 Warnings
⚠️ This PR introduced a violation in Firefox: /Account/FxAPushMessageHandler.swift#L160:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/SearchViewController.swift#L584:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/SearchViewController.swift#L596:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/SearchViewController.swift#L602:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/SearchViewController.swift#L609:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/SearchViewController.swift#L732:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/TabTrayController.swift#L827:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/TabTrayController.swift#L921:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Browser/TabTrayController.swift#L991:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/BookmarksPanel.swift#L489:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Intro/IntroViewController.swift#L418:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/RemoteTabsPanel.swift#L476:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/TopSitesPanel.swift#L357:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/Home/TopSitesPanel.swift#L514:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/# Management/#ListViewController.swift#L370:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/# Management/#ListViewController.swift#L568:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Client/Frontend/# Management/#ListViewController.swift#L605:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Extensions/NotificationService/ExtensionProfile.swift#L34:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Push/PushRegistration.swift#L62:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Providers/Profile.swift#L198:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Storage/SQL/SQLiteHistoryRecommendations.swift#L10:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Firefox: /Sync/SyncTelemetry.swift#L13:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Kickstarter-iOS/ViewModels/UpdateViewModel.swift#L8:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Library/Format.swift#L261:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Library/Format.swift#L263:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Library/Format.swift#L306:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Library/Format.swift#L315:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Library/Format.swift#L376:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Library/Koala/Koala.swift#L2115:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Kickstarter: /Library/ViewModels/RewardPledgeViewModel.swift#L1184:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Moya: /Sources/Moya/Plugins/NetworkLoggerPlugin.swift#L105:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Sources/Nimble/Adapters/NMBExpectation.swift#L5:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Sources/Nimble/Matchers/AsyncMatcherWrapper.swift#L10:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift#L5:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift#L6:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Tests/NimbleTests/Matchers/BeAnInstanceOfTest.swift#L7:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Tests/NimbleTests/Matchers/BeAKindOfTest.swift#L5:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Tests/NimbleTests/Matchers/BeAKindOfTest.swift#L6:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Tests/NimbleTests/Matchers/BeAKindOfTest.swift#L7:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Nimble: /Tests/NimbleTests/Matchers/BeAKindOfTest.swift#L8:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Realm: /RealmSwift/Sync.swift#L646:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in SourceKitten: /Source/SourceKittenFramework/CodeCompletionItem.swift#L11:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Sourcery: /Sourcery/main.swift#L49:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Sourcery: /Sourcery/Generating/Template/Swift/SwiftTemplate.swift#L14:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Sourcery: /Sourcery/Generating/Template/Swift/SwiftTemplate.swift#L19:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Sourcery: /Sourcery/Generating/Template/Swift/SwiftTemplate.swift#L208:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Sourcery: /Sourcery/Generating/Template/Swift/SwiftTemplate.swift#L217:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Sourcery: /SourceryTests/Helpers/CustomMatchers.swift#L91:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/Codable.swift#L19:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/Codable.swift#L20:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/NSObject.swift#L36:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L151:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L242:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L284:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L383:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L724:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L893:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L971:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L1006:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L1189:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L1998:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/JSONEncoder.swift#L2018:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L83:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L174:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L216:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L303:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L537:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L664:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L742:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L777:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L960:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L1661:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L1662:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in Swift: /stdlib/public/SDK/Foundation/PlistEncoder.swift#L1668:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/Extensions/UINavigationController+SplitViewFullscreen.swift#L3:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/Models/Post.swift#L7:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/Models/Post.swift#L20:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/Utility/PingHubManager.swift#L170:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/Utility/PingHubManager.swift#L207:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Me/AboutViewController.swift#L6:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Me/AboutViewController.swift#L19:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Me/AppSettingsViewController.swift#L242:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Media/MediaLibraryViewController.swift#L713:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L117:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L355:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L385:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L412:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L439:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L455:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L485:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostEditorState.swift#L495:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostListViewController.swift#L8:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/PostListViewController.swift#L21:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/AbstractPostListViewController.swift#L9:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Post/AbstractPostListViewController.swift#L22:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/ReaderMenuViewModel.swift#L7:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/ReaderMenuViewModel.swift#L20:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/ReaderPostCardCell.swift#L6:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/ReaderSiteStreamHeader.swift#L5:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
⚠️ This PR introduced a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/ReaderSiteStreamHeader.swift#L18:13: warning: Limit Fileprivate Violation: Prefer private over fileprivate for top-level declarations (fileprivate)
12 Messages
📖 Linting Aerial with this PR took 0.36s vs 0.33s on master (9% slower)
📖 Linting Alamofire with this PR took 2.34s vs 2.33s on master (0% slower)
📖 Linting Firefox with this PR took 10.14s vs 10.0s on master (1% slower)
📖 Linting Kickstarter with this PR took 13.04s vs 12.92s on master (0% slower)
📖 Linting Moya with this PR took 0.67s vs 0.67s on master (0% slower)
📖 Linting Nimble with this PR took 1.36s vs 1.33s on master (2% slower)
📖 Linting Quick with this PR took 0.43s vs 0.43s on master (0% slower)
📖 Linting Realm with this PR took 2.04s vs 2.01s on master (1% slower)
📖 Linting SourceKitten with this PR took 0.87s vs 0.87s on master (0% slower)
📖 Linting Sourcery with this PR took 2.81s vs 2.75s on master (2% slower)
📖 Linting Swift with this PR took 9.43s vs 9.4s on master (0% slower)
📖 Linting WordPress with this PR took 9.54s vs 9.51s on master (0% slower)

Generated by 🚫 Danger

@codecov-io
Copy link

codecov-io commented May 3, 2017

Codecov Report

Merging #1489 into master will increase coverage by 0.01%.
The diff coverage is 90.56%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1489      +/-   ##
==========================================
+ Coverage   88.08%   88.09%   +0.01%     
==========================================
  Files         196      198       +2     
  Lines        9791     9844      +53     
==========================================
+ Hits         8624     8672      +48     
- Misses       1167     1172       +5
Impacted Files Coverage Δ
.../SwiftLintFramework/Rules/IdentifierNameRule.swift 93.75% <ø> (ø) ⬆️
...sts/SwiftLintFrameworkTests/LinterCacheTests.swift 99.05% <ø> (ø) ⬆️
...s/SwiftLintFrameworkTests/ConfigurationTests.swift 94.24% <ø> (ø) ⬆️
Tests/SwiftLintFrameworkTests/RulesTests.swift 100% <100%> (ø) ⬆️
.../RuleConfigurations/FileprivateConfiguration.swift 75% <75%> (ø)
...rce/SwiftLintFramework/Rules/FileprivateRule.swift 96.87% <96.87%> (ø)

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 7b9f4da...985f9f7. Read the comment docs.

let violationOffsets = toplevel.flatMap { (offSet) -> Int? in
let parts = syntaxTokens.partitioned { offSet <= $0.offset }
guard let lastKind = parts.first.last,
lastKind.length == "fileprivate".bridge().length,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Full disclosure here: There is another builtin that has the same length as fileprivate. nonmutating has the same length of characters but nonmutating can never be toplevel in the current version of swift AFAIK. We could just file.substring to find out exactly what the builtin key is but that would slow down this pass.

@marcelofabri
Copy link
Collaborator

This doesn't close #1058 because my intention there is broader. For example, this should trigger:

class Foo {
    fileprivate var bar = ""

    func something() {
        print(bar)
    }
}

@masters3d
Copy link
Contributor Author

@marcelofabri That case is triggered in the strict mode. I just didn't think that part should be enforced as default because that could be a valid use case for some people.

@marcelofabri
Copy link
Collaborator

marcelofabri commented May 7, 2017

@marcelofabri That case is triggered in the strict mode. I just didn't think that part should be enforced as default because that could be a valid use case for some people.

My idea was to trigger only if we find out that the variable is only used in the current type scope (i.e. changing to private would still compile). See the following examples. I'd expect a violation on Example1, but not on Example2 - with Swift 3. When we add support for Swift 4, I'd expect a violation on both cases (because of SE-0169).

Example1:

class Foo {
    fileprivate var bar = ""

    func something() {
        print(bar)
    }
}

Example2:

class Foo {
    fileprivate var bar = ""
}

extension Foo {
    func printBar() {
        print(bar)
    }
}

I know that there's the strict mode, but that comes with false positives as well.

In a perfect scenario, I'd like this rule to always flag cases where fileprivate can be replaced with private without any doubts (i.e. can be autocorrectable). Then, with strict mode, all usages would be flagged, which would be helpful in Swift 4 as it'd mean "you're using fileprivate here, are you sure your abstraction model is right?".

I still think this is useful without implementing the full #1058 issue tough.

@masters3d
Copy link
Contributor Author

I see. I was thinking strict would be for people who do not want their code base to contain fileprivate at all. My thinking is, if people turn on the strict mode and still need fileprivate, they can disable it inline for the instances they want. I can remove the strict part for now if though since it is just a glorified regex.

@masters3d masters3d force-pushed the limit_fileprivate_usage branch 2 times, most recently from 79115ff to 7c0f637 Compare June 4, 2017 01:17
@masters3d
Copy link
Contributor Author

@marcelofabri I rebased this. Let me know if there is anything that would be blocking this.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Rule Request] Make all top level fileprivate decl become private
4 participants