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

Attributes rule bug #2297

Closed
2 tasks done
M0rtyMerr opened this issue Jul 18, 2018 · 1 comment
Closed
2 tasks done

Attributes rule bug #2297

M0rtyMerr opened this issue Jul 18, 2018 · 1 comment
Labels
bug Unexpected and reproducible misbehavior.

Comments

@M0rtyMerr
Copy link
Contributor

M0rtyMerr commented Jul 18, 2018

New Issue Checklist

Rule Request

If this is a bug report, please ignore this section.

If this is a new rule request, please ignore all sections below this one, format
this issue's title as Rule Request: [Rule Name] and describe:

  1. Why should this rule be added? Share links to existing discussion about what
    the community thinks about this.
  2. Provide several examples of what would and wouldn't trigger violations.
  3. Should the rule be configurable, if so what parameters should be configurable?
  4. Should the rule be opt-in or enabled by default? Why?
    See README.md for guidelines on when to mark a
    rule as opt-in.

Bug Report

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
...TagView.swift:13:25: warning: Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports. (attributes)
...TagListView.swift:12:20: warning: Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports. (attributes)
...TagListView.swift:19:33: warning: Attributes Violation: Attributes should be on their own lines in functions and types, but on the same line as variables and imports. (attributes)

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.26.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    CocoaPods
  • Paste your configuration file:
# insert yaml contents here
disabled_rules:
- conditional_returns_on_newline
- discouraged_object_literal
- explicit_acl
- explicit_top_level_acl
- explicit_type_interface
- explicit_enum_raw_value 
- function_default_parameter_at_end
- no_extension_access_modifier
- no_grouping_extension
- prefixed_toplevel_constant
- sorted_imports
- todo
#todo enable this
- file_header
- line_length 
- force_try
- force_cast
- trailing_closure
- force_unwrapping
- implicitly_unwrapped_optional
- object_literal

opt_in_rules:
- attributes
- array_init
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- contains_over_first_not_nil
- convenience_type
- discouraged_optional_boolean
- discouraged_optional_collection
- dynamic_inline
- empty_count
- empty_string
- empty_xctest_method
- explicit_init
- extension_access_modifier
- fallthrough
- fatal_error_message
- file_header
- file_name
- first_where
- force_unwrapping
- implicit_return
- implicitly_unwrapped_optional
- joined_default_parameter
- large_tuple
- let_var_whitespace
- literal_expression_end_indentation
- lower_acl_than_parent
- mark
- modifier_order
- multiline_arguments
- multiline_function_chains
- multiline_parameters
- nimble_operator
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- override_in_extension
- pattern_matching_keywords
- private_action
- private_outlet
- prohibited_super_call
- quick_discouraged_call
- quick_discouraged_focused_test
- quick_discouraged_pending_test
- redundant_nil_coalescing
- required_enum_case
- shorthand_operator
- single_test_class
- sorted_first_last
- strict_fileprivate
- switch_case_on_newline
- trailing_closure
- unavailable_function
- unneeded_parentheses_in_closure_argument
- untyped_error_in_catch
- vertical_parameter_alignment_on_call
- yoda_condition
attributes:
  always_on_same_line: ["@discardableResult", "@objc", "@IBAction", "@IBDesignable"]
  • Are you using nested configurations?
    No
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcode-select -p)?
    Version 9.4.1
  • 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.
// This triggers a violation:
@objc public protocol TagListViewDelegate {
    @objc optional func tagDidSelect(_ title: String, index: Int, tagView: TagView, sender: TagListView) //here
    @objc optional func tagDidDeselect(_ title: String, index: Int, tagView: TagView, sender: TagListView)
    @objc optional func tagRemoveButtonPressed(_ title: String, tagView: TagView, sender: TagListView)
}

@IBDesignable open class TagListView: UIView {

    @IBInspectable open dynamic var textColor: UIColor = UIColor.white { // and here
        didSet {
            for tagView in tagViews {
                tagView.textColor = textColor
            }
        }
    }

    @IBInspectable open dynamic var selectedTextColor: UIColor = UIColor.white {
        didSet {
            for tagView in tagViews {
                tagView.selectedTextColor = selectedTextColor
            }
        }
    }

It seems like problem in two lines one after the other with attribute.
If i change code like this, there are no errors:

@IBDesignable open class TagListView: UIView {
    let tmp = 5 // insert this line
    @IBInspectable open dynamic var textColor: UIColor = UIColor.white {
        didSet {
            for tagView in tagViews {
                tagView.textColor = textColor
            }
        }
    }
@realm-probot realm-probot bot added the O:User label Jul 18, 2018
@M0rtyMerr
Copy link
Contributor Author

Also, i can't disable it with // swiftlint:disable:next attributes, because it shows me Superfluous Disable Command Violation error.
So, the only way to deal with it - disabling for whole file

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Jul 19, 2018
dirtydanee pushed a commit to dirtydanee/SwiftLint that referenced this issue Aug 14, 2018
sjavora pushed a commit to sjavora/SwiftLint that referenced this issue Mar 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

No branches or pull requests

2 participants