Commit Graph

251 Commits

Author SHA1 Message Date
Marcelo Fabri c1650e6918 Add excludes_trivial_init for `missing_docs (#4152)
Fixes #4107
2022-09-03 22:11:57 -07:00
JP Simard 9979c4fd27 Add new self_binding opt-in rule (#4146)
To enforce that `self` identifiers are consistently re-bound to a common
identifier name.

Configure `bind_identifier` to the name you want to use.

Defaults to `self`.

Addresses https://github.com/realm/SwiftLint/issues/2495
2022-08-30 16:37:19 -04:00
Ben Davis 7dfadc205a Add new configuration to operator_usage_whitespace rule to specify no-space operators (#4112) 2022-08-25 17:59:27 +02:00
Danny Mösch 828f36958f Introduce option to ignore indentation of compiler directives in indentation_width rule (#4066) 2022-08-10 21:52:32 +02:00
JP Simard 0ded5859a1 Rewrite ColonRule with SwiftSyntax (#4063)
Making it about 7x faster, finding some previously missed cases.
2022-08-04 17:23:52 -04:00
Danny Mösch a51be7bcce Refactor deployment target configuration to avoid duplications (#4017) 2022-07-06 17:07:15 -04:00
Taha Bebek e34f49695b Support extension targets in deployment_target rule (#4011) 2022-07-05 22:41:56 +02:00
Marcelo Fabri a19ffddf66 Support arrays for included & excluded in custom rules (#4006)
* Support arrays for `included` & `excluded` in custom rules

* Extract shouldValidate(filePath:) and add tests
2022-06-27 00:29:26 -07:00
Chris Hale 9beef23175 Throw error on bad expiring todo date format (#3626) 2022-04-11 21:20:05 +02:00
JP Simard 54a24638a2 Print minimum_fraction_length in description even when unset 2022-03-03 12:49:11 -05:00
JP Simard 006bb2a85e Sort implicit return configuration description (#3823)
To make the output deterministic
2022-01-24 17:13:12 -08:00
Danny Mösch 050473a0e1 Add optional prefer_self_in_static_references rule (#3732) 2021-11-29 18:42:53 +00:00
Ben Fox 00799cc782 Fixes MissingDocRuleConfiguration (#3713)
* add configuration for missing_docs

* fix MissingDocsRuleConfiguration

* add to changelog

* fix up Config default values and update tests

* use XCTAssertTrue and XCTAssertFalse

* fix line length violation

* finish up unit tests

* rever Package.resolved
2021-09-13 15:23:55 -04:00
Ben Fox 1f44d56357 add configuration for missing_docs (#3701)
* `excludes_extensions` defaults to `true` to skip reporting violations
  for extensions with missing documentation comments.
* `excludes_inherited_types` defaults to `true` to skip reporting
  violations for inherited declarations, like subclass overrides.
2021-09-01 21:42:47 +00:00
Dylan Maryk 5a3844401b Fix missing comma in description (#3588) 2021-04-27 22:51:37 -07:00
Artem Garmash 4266ea9d60 Add Bool violation reporting in redundant_type_annotation (#3438)
* Add Bool violation detection

* Update Changelog

* Fix issues found by the rule
2021-02-24 14:29:08 -08:00
JP Simard 60242fd599 [UnusedDeclarationRule] Allow configuration related USRs to skip (#3525)
For example you might have custom source tooling that does something
with types conforming to a procotol even if that type is never
explicitly referenced by other code.
2021-02-17 12:25:23 -08:00
Otavio Cordeiro 7ea9b733ff Allow multi-line parameters rule to always break lines (#3494) 2021-02-02 13:27:29 -08:00
Yurii Kotov 6dba929b4f Fix typos in configuration options for file_name rule 2020-12-16 19:56:50 +02:00
Dalton Claybrook ba5e6d2e1c Fix false positives in inclusive_language rule (#3439)
* Add support for allowed terms in inclusive language rule

* Update changelog

* Move changelog entry to Enhancements section

Co-authored-by: JP Simard <jp@jpsim.com>
2020-11-20 14:12:24 -05:00
Bryan Ricker 999bfbdefa Fix consoleDescription for OverriddenSuperCallConfiguration 2020-11-10 20:40:41 -08:00
Bryan Ricker 8a0eb67561 chore: rename OverridenSuperCallConfiguration to OverriddenSuperCallConfiguration
BREAKING CHANGE: As `OverridenSuperCallConfiguration` is a
publicly-exposed struct, this rename should be considered breaking.
2020-11-10 20:40:41 -08:00
JP Simard bf2790df54 Enable CommentSpacingRule by default
And fix violations in SwiftLint
2020-11-10 12:50:39 -05:00
JP Simard d9b5df2d72 Merge pull request #3254 from realm/ks/add-always_keep_imports-to-unusedimportrule
Add 'always_keep_imports' to UnusedImportRule
2020-11-09 17:43:20 -05:00
JP Simard 46ed5e2ece Add print statement for deprecation
To indicate that `statement_level` has been renamed to `function_level`.
2020-11-09 12:06:45 -05:00
JP Simard aa02a8aec0 Apply small refactorings 2020-11-09 12:06:44 -05:00
Skoti b9841595a5 Separated nesting level counting for types and functions in nesting rule (fixes #1151). Enhanced nesting rule to search for nested types and functions within closures and statements. Enhanced nesting rule to allow for one nested type within a function even if breaking a maximum type level nesting (fixes #1151). 2020-11-09 12:06:34 -05:00
Paul Taykalo ba58d571d8 Add option that allows skipping aligned constants (#3391) 2020-11-08 10:07:24 -05:00
Dalton Claybrook d305e03905 Add inclusive_language rule (#3243)
Current events have renewed the conversation in our community about the roles of terminology with racist connotations in our software. Many companies and developers are now taking appropriate steps to remove this terminology from their codebases and products. (e.g. [GitHub](https://twitter.com/natfriedman/status/1271253144442253312)) This small rule prevents the use of declarations that contain any of the terms: whitelist, blacklist, master, and slave. It may be appropriate to add more terms to this list now or in the future.
2020-11-07 22:03:08 -05:00
Paul Taykalo 693ee2cae9 Add Isnot Empty extension in the Swift Framework (#3387) 2020-11-07 18:42:55 -05:00
Zsolt Kovács ac2c5e4054 Allow opening brace on newline in case of multiline function (#3068) 2020-11-07 16:02:17 -05:00
Keith Smiley 5d6e25ae5f Add TestCaseAccessibilityRule (#3376)
Co-authored-by: JP Simard <jp@jpsim.com>
2020-10-12 08:59:45 -07:00
Ryan Demo 51544bb4cc Add excluded_match_kinds custom rule config parameter (#3336)
This allows custom rules to define an `excluded_match_kinds` array instead of listing out all but one or a few of the `SyntaxKind`s in `match_kinds`. Rules that include both `match_kinds` and `excluded_match_kinds` will be invalid, since there's not an obvious way to resolve the two without an arbitrary priority between them.
2020-09-10 21:08:41 -04:00
Marcelo Fabri f8ef7d649c Enable legacy_multiple and prefer_self_type_over_type_of_self in our codebase 2020-08-05 01:11:17 -07:00
Marcelo Fabri 240e25232f Add computed_accessors_order rule
Fixes #3158
2020-08-04 03:23:36 -07:00
Keith Smiley 660920a5f8 Add 'always_keep_imports' to UnusedImportRule
Sometimes we hit issues with SourceKit that cause this rule to produce
false positives of some imports. While we would prefer to fix all of
these cases whenever possible, this gives us a temporary escape hatch to
tell the rule never to remove imports of specific modules until the
fixes land in SwiftLint or Swift itself.

Currently this is for us to opt out of https://bugs.swift.org/browse/SR-13120
2020-06-30 10:00:33 -07:00
Cihat Gündüz 5a22b94ec6 Add new file_content_type for PreviewProvider subclasses (#3063)
Fixes #2860.

Co-authored-by: Paul Taykalo <tt.kilew@gmail.com>
2020-04-24 13:21:24 +03:00
JP Simard d10ccacb45 Add unused_import config options to require imports for each module used (#3123)
For example, if `CGFloat` is used in a file where only `UIKit` is imported but not `CoreGraphics`, this will be a violation even if the file previously compiled.

This is because Swift allows referencing some declarations that are only transitively imported.

Enabling the `require_explicit_imports` configuration option will require that the module of every declaration referenced in a source file be explicitly imported.

This will add significant noise to the imports list, but has a few advantages:

1. It will be easier to understand all the dependencies explicitly referenced in a source file.
2. Correcting the `unused_import` rule will no longer introduce compilation errors in files that compiled prior to the correction.

If missing imports are added to a file when correcting it, the `sorted_imports` rule will be automatically run on that file.

If you with to allow some imports to be implicitly importable transitively, you may specify the `allowed_transitive_imports` configuration:

```yaml
unused_import:
  require_explicit_imports: true
  allowed_transitive_imports:
    - module: Foundation
      allowed_transitive_imports:
        - CoreFoundation
        - Darwin
        - ObjectiveC
```
2020-02-22 14:39:07 -08:00
Zsolt Kovács ab8cd43e67 Empty count configuration (#3052)
* Add `only_after_dot` configuration option to `empty_count` rule

* Update CHANGELOG.md

* Adopt Example wrapper

* Change severity level to error
2020-02-09 15:12:54 -08:00
John Buckley efe8816315 ImplicitReturnConfiguration description now reports current config (#3083)
* ImplicitReturnConfiguration description now reports current config.

Previously only the default config was reported.

* Updating CHANGELOG.md
2020-02-08 01:55:58 -08:00
Steven 325af44c36 Add deinitializer to type_contents_order (#3042)
Add `deinitializer` type content to `type_contents_order` rule instead of grouping it with initializers. This allows the common use case of putting the deinitializer at the end of the class.
2020-01-16 16:49:37 -08:00
JP Simard 399f5b7df6 Fix docstring formatting issues using DrString (#3032)
Using command:
$ drstring check -i 'Source/**/*.swift' --first-letter lowercase --vertical-align
2020-01-12 11:19:33 -08:00
JP Simard 37167a8a35 Add documentation comments to all public declarations (#3027) 2020-01-08 09:47:10 -08:00
JP Simard d2643db495 [Docs] Build docs using jazzy (#3016)
* Add `.jazzy.yaml` configuration file
* Update `swiftlint generate-docs` to write docs to a directory rather than a single file
* Add jazzy to the Gemfile
* Run `bundle update`
* Add CI job to run jazzy automatically and publish to GitHub Pages

![swiftlint-jazzy](https://user-images.githubusercontent.com/474794/71799038-fcf4e180-3008-11ea-81fa-3eb9cf296506.gif)
2020-01-07 20:31:29 -08:00
Frederick Pietschmann 98e870e726 Fix modifier order 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 3a8ad943c3 Add configuration option whether to consider comment lines for indentation_width rule 2020-01-06 08:30:49 +01:00
Frederick Pietschmann 8c245c7581 Add new indentation_width rule 2020-01-06 08:30:49 +01:00
Pyry Jahkola 805b9ab3ba Add capture_group option to custom_rules
This option allows for more fine-grained placement of the location
marker for code violating a custom rule, e.g.:

```swift
print("Hello world.")
             ^~~~~
```

for this `.swiftlint.yml`:

```yaml
custom_rules:
  world_preceded_by_hello:
    name: "World Preceded by Hello"
    included: ".+\\.swift"
    message: "The word World predeced by the word hello should be capitalised."
    severity: warning
    regex: "(?i:hello)\\s+(world)"
    match_kinds: [string]
    capture_group: 1
```
2020-01-05 15:24:11 -08:00
Sven Münnich 72e2063531 Include functions and getters in rule implicit_return 2020-01-05 15:04:35 -08:00
timcmiller 4112816077 Added 'file_name_no_space' rule (#3008)
* Added 'file_name_no_space' rule

* Removed unused var, and added to changelog

* Remove custom suffix from 'file-name-no-space' rule

* Fixed LinuxMain

* Switched to use a CharacterSet over Regex
2020-01-03 15:45:30 -08:00