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

Add codeclimate reporter #3425

Merged
merged 5 commits into from
Nov 11, 2020
Merged

Add codeclimate reporter #3425

merged 5 commits into from
Nov 11, 2020

Conversation

jkroepke
Copy link
Contributor

Fixes: #3424

@SwiftLintBot
Copy link

SwiftLintBot commented Nov 10, 2020

12 Messages
📖 Linting Aerial with this PR took 2.01s vs 1.96s on master (2% slower)
📖 Linting Alamofire with this PR took 2.78s vs 2.83s on master (1% faster)
📖 Linting Firefox with this PR took 9.47s vs 9.38s on master (0% slower)
📖 Linting Kickstarter with this PR took 15.81s vs 15.55s on master (1% slower)
📖 Linting Moya with this PR took 1.51s vs 1.41s on master (7% slower)
📖 Linting Nimble with this PR took 1.39s vs 1.4s on master (0% faster)
📖 Linting Quick with this PR took 0.64s vs 0.69s on master (7% faster)
📖 Linting Realm with this PR took 4.54s vs 4.51s on master (0% slower)
📖 Linting SourceKitten with this PR took 1.03s vs 1.07s on master (3% faster)
📖 Linting Sourcery with this PR took 7.27s vs 7.23s on master (0% slower)
📖 Linting Swift with this PR took 11.42s vs 11.37s on master (0% slower)
📖 Linting WordPress with this PR took 17.62s vs 17.54s on master (0% slower)

Generated by 🚫 Danger

@jkroepke jkroepke force-pushed the codeclimate-reporter branch 4 times, most recently from be6d9ee to 17fe2f3 Compare November 10, 2020 20:41
@jkroepke
Copy link
Contributor Author

Please Review.

One question: The path inside the report is escaped. This is expected?

  {
    "check_name" : "identifier_name",
    "description" : "Variable name should be between 3 and 40 characters long: 'to'",
    "engine_name" : "SwiftLint",
    "fingerprint" : "cc6071d559206b5f6487194ee6b3776c",
    "location" : {
      "lines" : {
        "begin" : 95
      },
      "path" : "\/Users\/jkr\/Documents\/app\/ios\/Pods\/lottie-ios\/lottie-swift\/src\/Private\/Utility\/Extensions\/MathKit.swift"
    },
    "severity" : "MINOR",
    "type" : "issue"
  },

@jkroepke jkroepke marked this pull request as ready for review November 10, 2020 20:46
@jkroepke jkroepke changed the title WIP: Add codeclimate reporter Add codeclimate reporter Nov 10, 2020
@jpsim
Copy link
Collaborator

jpsim commented Nov 10, 2020

This is expected?

I think that's more of a question for you, what does the Codeclimate format expect?

@jkroepke
Copy link
Contributor Author

jkroepke commented Nov 10, 2020

I couldn't find the spec yet. I followed https://github.com/codeclimate/codeclimate-swiftlint/blob/3cfa6c59e4f66b185e407a4293d5175cf52799ed/Sources/codeclimate-SwiftLint/main.swift#L16

Looking at the gitlab example, the path is not escaped:
https://docs.gitlab.com/ee/user/project/merge_requests/code_quality.html#implementing-a-custom-tool

I thought swiftlint escape the slashes by default. But it looks like a swift feature. (First time doing something with swift...)

I changed it.

CHANGELOG.md Outdated Show resolved Hide resolved
@jpsim
Copy link
Collaborator

jpsim commented Nov 10, 2020

Looks good other than the md5 code duplication.

Comment on lines 1 to 9
#if canImport(CommonCrypto)
import CommonCrypto
#else
import CryptoSwift
#endif
import Foundation

#if canImport(CommonCrypto)
extension String {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Aren't all these other imports unused?

Suggested change
#if canImport(CommonCrypto)
import CommonCrypto
#else
import CryptoSwift
#endif
import Foundation
#if canImport(CommonCrypto)
extension String {
#if canImport(CommonCrypto)
import CommonCrypto
extension String {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought CryptoSwift is just fallback, if CommonCrypto is not available.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Correct, but CryptoSwift already comes with String.md5(), so what this code does is add the same convenience method to CommonCrypto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied the code from Source/SwiftLintFramework/Extensions/Configuration+Cache.swift, I can't decide if the code could be throw away.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That file uses CryptoSwift but this file doesn’t.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggest to split this in an own issue/pr.

@jkroepke
Copy link
Contributor Author

Rebased.

Could we merge is feature soon? Looks like the CHANGELOG.md gets conflicted fast if any other PR is merged.

I still suggest to split the discussion about the crypto code in a separate PR.

@jpsim
Copy link
Collaborator

jpsim commented Nov 11, 2020

Thanks for rebasing and keeping this up to date. I pushed up the import changes I had mentioned, fixed the changelog entry and will be merging once CI passes. Thanks for your contribution @jkroepke!

@jkroepke
Copy link
Contributor Author

Thanks!

@jpsim jpsim merged commit 874cacb into realm:master Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Codeclimate report format for Gitlab MR Widget
3 participants