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

Typealias considered defining a Type with nesting #3183

Open
2 tasks done
matteobart opened this issue Apr 20, 2020 · 6 comments
Open
2 tasks done

Typealias considered defining a Type with nesting #3183

matteobart opened this issue Apr 20, 2020 · 6 comments
Labels
enhancement Ideas for improvements of existing features and rules. good first issue Issue to be taken up by new contributors yet unfamiliar with the project.

Comments

@matteobart
Copy link

New Issue Checklist

Describe the bug

Defining a typealias is considered to be creating type. This is problem when it is nested. I don't believe that this is to be the expected behavior especially since this can be unavoidable behavior when using Decodables with Protocols.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
/.../SpotifyItems.swift:129:16: warning: Nesting Violation: Types should be nested at most 1 level deep (nesting)

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.39.2
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
  • Paste your configuration file:
identifier_name:
    excluded: # excluded via string array
      - id
      - me
  • Are you using nested configurations? Nope
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 11.4 Build version 11E146
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
public struct SpotifyPlaylist: Decodable {
    public struct Tracks: SpotifyPagingObject {
        public var items: [Item]?
        public typealias ItemType = Item // This triggers a violation
    }
    public struct Item: Decodable {
        public var track: SpotifyTrack
    }
}
struct AStruct {
    struct BStruct {
        typealias GreatType = C.Type
    }
    struct CStruct {

    }
}
<nopath>:2:5: warning: Convenience Type Violation: Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation. (convenience_type)
<nopath>:1:1: warning: Convenience Type Violation: Types used for hosting only static members should be implemented as a caseless enum to avoid instantiation. (convenience_type)
<nopath>:3:9: warning: Explicit ACL Violation: All declarations should specify Access Control Level keywords explicitly. (explicit_acl)
<nopath>:2:5: warning: Explicit ACL Violation: All declarations should specify Access Control Level keywords explicitly. (explicit_acl)
<nopath>:5:5: warning: Explicit ACL Violation: All declarations should specify Access Control Level keywords explicitly. (explicit_acl)
<nopath>:1:1: warning: Explicit ACL Violation: All declarations should specify Access Control Level keywords explicitly. (explicit_acl)
<nopath>:1:1: warning: Explicit Top Level ACL Violation: Top-level declarations should specify Access Control Level keywords explicitly. (explicit_top_level_acl)
**<nopath>:3:9: warning: Nesting Violation: Types should be nested at most 1 level deep (nesting)**
<nopath>:6:1: warning: Vertical Whitespace before Closing Braces Violation: Don't include vertical whitespace (empty line) before closing braces. (vertical_whitespace_closing_braces)
<nopath>:6:1: warning: Vertical Whitespace after Opening Braces Violation: Don't include vertical whitespace (empty line) after opening braces. (vertical_whitespace_opening_braces)
@stale
Copy link

stale bot commented Nov 8, 2020

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@stale stale bot added the wontfix Issues that became stale and were auto-closed by a bot. label Nov 8, 2020
@matteobart
Copy link
Author

This is still an issue, just commenting to keep it from going stale

@stale stale bot removed the wontfix Issues that became stale and were auto-closed by a bot. label Nov 11, 2020
@stale
Copy link

stale bot commented Jan 10, 2021

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

@stale stale bot added the wontfix Issues that became stale and were auto-closed by a bot. label Jan 10, 2021
@matteobart
Copy link
Author

Bump

@stale stale bot removed the wontfix Issues that became stale and were auto-closed by a bot. label Jan 14, 2021
@SimplyDanny SimplyDanny added the enhancement Ideas for improvements of existing features and rules. label Sep 10, 2022
@SimplyDanny
Copy link
Collaborator

One solution would be to add a configuration option to exclude type aliases and associated types from the analysis of the rule.

@marunomi
Copy link
Contributor

@SimplyDanny
plz check this out :)

This is my first time creating a pull request for OSS, so I would appreciate comments on any shortcomings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Ideas for improvements of existing features and rules. good first issue Issue to be taken up by new contributors yet unfamiliar with the project.
Projects
None yet
Development

No branches or pull requests

3 participants