Skip to content

Commit

Permalink
Merge branch 'master' into 701/initial-editorconfig-integration
Browse files Browse the repository at this point in the history
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
  • Loading branch information
Tapchicoma committed Sep 17, 2020
2 parents 9ba5651 + e3d7a60 commit 79c4bcb
Show file tree
Hide file tree
Showing 26 changed files with 1,381 additions and 897 deletions.
7 changes: 6 additions & 1 deletion .announce
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ if [[ "$AUTOACCEPT" = false ]]; then
read -p "commit & push (y/n)? " -n 1 -r; echo; if [[ ! $REPLY =~ ^[Yy]$ ]]; then exit 1; fi
fi

git commit -m "$COMMIT_MESSAGE" README.md && git push origin master
BRANCH="$VERSION-update-refs"

# Make a separate branch because master branch is protected
git checkout --track origin/master -b $BRANCH && git commit -m "$COMMIT_MESSAGE" README.md && git push origin $BRANCH

open "https://github.com/pinterest/ktlint/compare/$BRANCH?expand=1"

# update ktlint.github.io

Expand Down
7 changes: 7 additions & 0 deletions .homebrew
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# project.version
if [ "$VERSION" == "" ]; then exit 1; fi

brew update
shasum -a 256 ./ktlint/build/run/ktlint | awk -v new_version="$VERSION" '{system(sprintf("brew bump-formula-pr --url=\"https://github.com/pinterest/ktlint/releases/download/%s/ktlint\" --sha256=\"%s\"", new_version, $1))}'
1 change: 1 addition & 0 deletions ADOPTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ adds your information to this file.
- [Duolingo](https://www.duolingo.com/)
- [Ellation](http://www.ellation.com/)
- [Faithlife](https://faithlife.com/about)
- [Flickr](https://flickr.com)
- [Freeletics](https://www.freeletics.com)
- [Gradle](https://gradle.org)
- [M1 Finance](https://www.m1finance.com/)
Expand Down
28 changes: 27 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,43 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Added
- Initial implementation IDE integration via '.editorconfig' based on rules default values ([#701](https://github.com/pinterest/ktlint/issues/701))

### Fixed
- ?

### Changed
- ?

### Removed
- ?

## [0.39.0] - 2020-09-14

### Added
- Add new applyToIDEA location for IDEA 2020.1.x and above on MacOs
- Debug output: print loaded .editorconfig content
- Initial implementation IDE integration via '.editorconfig' based on rules default values ([#701](https://github.com/pinterest/ktlint/issues/701))
- Extract `argument-list-wrapping` rule into experimental ruleset
- Split `annotation-spacing` into separate experimental rule

### Fixed
- Do not enforce raw strings opening quote to be on a separate line ([#711](https://github.com/pinterest/ktlint/issues/711))
- False negative with multiline type parameter list in function signature for `parameter-list-wrapping`([#680](https://github.com/pinterest/ktlint/issues/680))
- Alternative `.editorconfig` path is ignored on stdin input ([#869](https://github.com/pinterest/ktlint/issues/869))
- False positive with semicolons before annotations/comments/kdoc ([#825](https://github.com/pinterest/ktlint/issues/825))
- Do not report when string-template expression is a keyword ([#883](https://github.com/pinterest/ktlint/issues/883))
- False positive for subclass imports in `no-unused-imports` ([#845](https://github.com/pinterest/ktlint/issues/845))
- False positive for static java function imports in `no-unused-imports` ([#872](https://github.com/pinterest/ktlint/issues/872))
- Missing signature for KtLint CLI artifact published to Github release ([#895](https://github.com/pinterest/ktlint/issues/895))
- Crash in annotation rule ([#868](https://github.com/pinterest/ktlint/issues/868))
- False-positive unused import violation ([#902](https://github.com/pinterest/ktlint/issues/902))

### Changed
- `Ktlint` object internal code cleanup
- Deprecate some of public methods in `Ktlint` object that should not be exposed as public api
- Update Kotlin to 1.4.10 version
- Make `RuleSet` class open so it can be inherited

## [0.38.1] - 2020-08-24
Minor release to support projects using mixed 1.3/1.4 Kotlin versions (e.g. Gradle plugins)
Expand Down Expand Up @@ -753,6 +778,7 @@ set in `[*{kt,kts}]` section).

## 0.1.0 - 2016-07-27

[0.39.0]: https://github.com/pinterest/ktlint/compare/0.38.1...0.39.0
[0.38.1]: https://github.com/pinterest/ktlint/compare/0.38.0...0.38.1
[0.38.0]: https://github.com/pinterest/ktlint/compare/0.37.2...0.38.0
[0.37.2]: https://github.com/pinterest/ktlint/compare/0.37.1...0.37.2
Expand Down
69 changes: 38 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,41 @@ It's also [easy to create your own](#creating-a-reporter).

## Standard rules

- Indentation formatting - respects `.editorconfig` `indent_size` with no continuation indent (see [EditorConfig](#editorconfig) section for more)
- No semicolons (unless used to separate multiple statements on the same line)
- No unused `import`s
- No consecutive blank lines
- No blank lines before `}`
- No trailing whitespaces
- No `Unit` returns (`fun fn {}` instead of `fun fn: Unit {}`)
- No empty (`{}`) class bodies
- No spaces around range (`..`) operator
- No newline before (binary) `+` & `-`, `*`, `/`, `%`, `&&`, `||`
- No wildcard `import`s
- When wrapping chained calls `.`, `?.` and `?:` should be placed on the next line
- When a line is broken at an assignment (`=`) operator the break comes after the symbol
- Indentation formatting - respects `.editorconfig` `indent_size` with no continuation indent (see [EditorConfig](#editorconfig) section for more) (id: `indent`)
- No semicolons (unless used to separate multiple statements on the same line) (id: `no-semi`)
- No unused `import`s (id: `no-unused-imports`)
- No consecutive blank lines (id: `no-consecutive-blank-lines`)
- No blank lines before `}` (id: `no-blank-line-before-rbrace`)
- No trailing whitespaces (id: `no-trailing-spaces`)
- No `Unit` returns (`fun fn {}` instead of `fun fn: Unit {}`) (id: `no-unit-return`)
- No empty (`{}`) class bodies (id: `no-empty-class-body`)
- No wildcard `import`s (id: `no-wildcard-imports`)
- When wrapping chained calls `.`, `?.` and `?:` should be placed on the next line (id: `chain-wrapping`)
- When a line is broken at an assignment (`=`) operator the break comes after the symbol (id: `no-line-break-before-assignment`)
- When class/function signature doesn't fit on a single line, each parameter must be on a separate line
- Consistent string templates (`$v` instead of `${v}`, `${p.v}` instead of `${p.v.toString()}`)
- Consistent order of modifiers
- Consistent spacing after keywords, commas; around colons, curly braces, parens, infix operators, comments, etc
- Newline at the end of each file (enabled by default)
(set `insert_final_newline=false` in .editorconfig to disable (see [EditorConfig](#editorconfig) section for more)).
- Imports ordered consistently (see [Custom ktlint EditorConfig properties](#custom-ktlint-specific-editorconfig-properties) for more)
- Consistent string templates (`$v` instead of `${v}`, `${p.v}` instead of `${p.v.toString()}`) (id: `string-template`)
- Consistent order of modifiers (id: `modifier-order`)
- Consistent spacing after keywords, commas; around colons, curly braces, parens, infix operators, comments, range operators, etc (ids: `colon-spacing`, `comma-spacing`, `curly-spacing`, `dot-spacing`, `double-colon-spacing`, `keyword-spacing`, `op-spacing`, `paren-spacing`, `range-spacing`)
- Newline at the end of each file (enabled by default)
(set `insert_final_newline=false` in .editorconfig to disable (see [EditorConfig](#editorconfig) section for more)). (id: `final-newline`)
- Imports ordered consistently (see [Custom ktlint EditorConfig properties](#custom-ktlint-specific-editorconfig-properties) for more) (id: `import-ordering`)

## Experimental rules
New rules will be added into the [experimental ruleset](https://github.com/pinterest/ktlint/tree/master/ktlint-ruleset-experimental), which can be enabled
by passing the `--experimental` flag to `ktlint`.

- Annotation formatting - multiple annotations should be on a separate line than the annotated declaration; annotations with parameters should each be on separate lines; annotations should be followed by a space; declarations with annotations should be separated by a blank line
- Comment space formatting - declarations with comments should be separated by a blank line
- No underscores in package names
- Braces required for multiline if/else statements
- Enum entry names should be uppercase underscore-separated names
- No spaces around `::`
- No spaces around angle brackets
- Annotation formatting - multiple annotations should be on a separate line than the annotated declaration; annotations with parameters should each be on separate lines; annotations should be followed by a space (id: `experimental:annotation`)
- Annotations should be separated by the annotated declaration by a single line break (id: `experimental:annotation-spacing`)
- Argument list wrapping (id: `experimental:argument-list-wrapping`)
- Enum entry names should be uppercase underscore-separated names (id: `experimental:enum-entry-name-case`)
- Braces required for multiline if/else statements (id: `experimental:multiline-if-else`)
- No leading empty lines in method blocks (id: `experimental:no-empty-first-line-in-method-block`)
- No underscores in package names (id: `experimental:package-name`)
- No spaces around angle brackets (id: `experimental:spacing-around-angle-brackets`)
- No spaces around `::` (id: `experimental:double-colon-spacing`)
- No spaces around unary operators (id: `experimental:unary-op-spacing`)
- Declarations with annotations should be separated by a blank line (id: `experimental:spacing-between-declarations-with-annotations`)
- Declarations with comments should be separated by a blank line (id: `experimental:spacing-between-declarations-with-comments`)


## EditorConfig
Expand Down Expand Up @@ -119,12 +122,16 @@ disabled_rules=indent
> Skip all the way to the "Integration" section if you don't plan to use `ktlint`'s command line interface.
```sh
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.38.1/ktlint &&
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.39.0/ktlint &&
chmod a+x ktlint &&
sudo mv ktlint /usr/local/bin/
```

... or just download `ktlint` from the [releases](https://github.com/pinterest/ktlint/releases) page (`ktlint.asc` contains PGP signature which you can verify with `curl -sS https://keybase.io/pinterestandroid/pgp_keys.asc | gpg --import && gpg --verify ktlint.asc`).
... or just download `ktlint` from the [releases](https://github.com/pinterest/ktlint/releases) page

* `ktlint.asc` contains PGP signature which you can verify with:
* (Releases up through 0.31.0) `curl -sS https://keybase.io/shyiko/pgp_keys.asc | gpg --import && gpg --verify ktlint.asc`
* (Releases from 0.32.0 on) `curl -sS https://keybase.io/ktlint/pgp_keys.asc | gpg --import && gpg --verify ktlint.asc`

On macOS ([or Linux](http://linuxbrew.sh/)) you can also use [brew](https://brew.sh/) - `brew install ktlint`.

Expand Down Expand Up @@ -215,7 +222,7 @@ $ ktlint installGitPreCommitHook
<dependency>
<groupId>com.pinterest</groupId>
<artifactId>ktlint</artifactId>
<version>0.38.1</version>
<version>0.39.0</version>
</dependency>
<!-- additional 3rd party ruleset(s) can be specified here -->
</dependencies>
Expand Down Expand Up @@ -263,7 +270,7 @@ configurations {
}
dependencies {
ktlint "com.pinterest:ktlint:0.38.1"
ktlint "com.pinterest:ktlint:0.39.0"
// additional 3rd party ruleset(s) can be specified here
// just add them to the classpath (e.g. ktlint 'groupId:artifactId:version') and
// ktlint will pick them up
Expand Down Expand Up @@ -302,7 +309,7 @@ See [Making your Gradle tasks incremental](https://proandroiddev.com/making-your
val ktlint by configurations.creating

dependencies {
ktlint("com.pinterest:ktlint:0.38.1")
ktlint("com.pinterest:ktlint:0.39.0")
// ktlint(project(":custom-ktlint-ruleset")) // in case of custom ruleset
}

Expand Down
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

ext.versions = [
'kotlin': gradle.ext.isKotlinDev ? '1.4.10-rc-345' : '1.4.0',
'kotlin': gradle.ext.isKotlinDev ? "1.4.20-dev-3947" : "1.4.10",
'gradle': '6.6',
'gradle-sha256': 'e6f83508f0970452f56197f610d13c5f593baaf43c0e3c6a571e5967be754025'
]
Expand Down Expand Up @@ -121,7 +121,8 @@ githubRelease {
project(":ktlint").tasks.named("shadowJarExecutable").get()
.outputs
.files
.singleFile
.getFiles()
.first()
.parentFile
.listFiles()
})
Expand Down Expand Up @@ -150,10 +151,18 @@ def announceTask = tasks.register("announceRelease", Exec.class) { announceTask
environment GITHUB_TOKEN: "${getGithubToken()}"
}

def homebrewTask = tasks.register("homebrewBumpFormula", Exec.class) { homebrewTask ->
group "Help"
description "Runs brew bump-forumula-pr"
commandLine './.homebrew'
environment VERSION: "${project.'VERSION_NAME'}"
dependsOn(tasks.named("githubRelease"))
}

tasks.register("publishNewRelease", DefaultTask.class) {
group = "Help"
description = "Triggers uploading new archives and publish announcements"
dependsOn(announceTask, tasks.named("githubRelease"))
dependsOn(announceTask, homebrewTask, tasks.named("githubRelease"))
}

tasks.withType(Wrapper).configureEach {
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/ktlint-publication.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ publishing {
* ```
*/
signing {
// Uncomment following line to use gpg-agent for signing
// See https://docs.gradle.org/current/userguide/signing_plugin.html#sec:using_gpg_agent how to configure it
//useGpgCmd()

sign(publishing.publications["maven"])
setRequired({
!version.toString().endsWith("SNAPSHOT")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=0.39.0-SNAPSHOT
VERSION_NAME=0.40.0-SNAPSHOT

POM_DESCRIPTION=An anti-bikeshedding Kotlin linter with built-in formatter.

Expand Down

0 comments on commit 79c4bcb

Please sign in to comment.