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

Use Sourcery to generate LinuxMain.swift & MasterRuleList.swift #1592

Merged
merged 4 commits into from
Jun 2, 2017

Conversation

jpsim
Copy link
Collaborator

@jpsim jpsim commented Jun 1, 2017

Extends #1591 by also automatically generating MasterRuleList.swift

@SwiftLintBot
Copy link

SwiftLintBot commented Jun 1, 2017

3 Warnings
⚠️ Big PR
⚠️ Please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
⚠️ Permanently added the RSA host key for IP address ‘192.30.253.113’ to the list of known hosts.
12 Messages
📖 Linting Aerial with this PR took 0.38s vs 0.33s on master (15% slower)
📖 Linting Alamofire with this PR took 2.26s vs 2.26s on master (0% slower)
📖 Linting Firefox with this PR took 10.15s vs 10.08s on master (0% slower)
📖 Linting Kickstarter with this PR took 13.32s vs 12.86s on master (3% slower)
📖 Linting Moya with this PR took 0.69s vs 0.67s on master (2% slower)
📖 Linting Nimble with this PR took 1.33s vs 1.3s on master (2% slower)
📖 Linting Quick with this PR took 0.44s vs 0.43s on master (2% slower)
📖 Linting Realm with this PR took 2.04s vs 2.02s on master (0% slower)
📖 Linting SourceKitten with this PR took 0.86s vs 0.85s on master (1% slower)
📖 Linting Sourcery with this PR took 2.73s vs 2.76s on master (1% faster)
📖 Linting Swift with this PR took 9.41s vs 9.37s on master (0% slower)
📖 Linting WordPress with this PR took 9.86s vs 9.56s on master (3% slower)

Here's an example of your CHANGELOG entry:

* Use Sourcery to generate LinuxMain.swift & MasterRuleList.swift.  
  [jpsim](https://github.com/jpsim)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by 🚫 Danger

@@ -100,17 +33,17 @@ public let masterRuleList = RuleList(rules:
FileHeaderRule.self,
FileLengthRule.self,
FirstWhereRule.self,
ForWhereRule.self,
Copy link
Collaborator

Choose a reason for hiding this comment

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

shouldn't we keep the sort order as case insensitive?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sourcery returns these already sorted, and I don't think there's a way to re-sort. Is this a problem?

Copy link
Collaborator

Choose a reason for hiding this comment

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

no, just wanted to see if it was possible to do it 👍

@jpsim jpsim changed the title Use Sourcery to generate MasterRuleList.swift Use Sourcery to generate LinuxMain.swift & MasterRuleList.swift Jun 1, 2017
@@ -28,6 +28,16 @@ VERSION_STRING=$(shell /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionSt
all: bootstrap
$(BUILD_TOOL) $(XCODEFLAGS) build

sourcery:
sourcery --sources Tests --templates .sourcery/LinuxMain.stencil --output .sourcery
Copy link
Contributor

Choose a reason for hiding this comment

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

If you add to the top of the template the target file, it will override it instead of creating .generated.swift
// sourcery:file:Tests/LinuxMain.swift
https://twitter.com/ilyapuchka/status/847567291302674434
https://oleb.net/blog/2017/03/keeping-xctest-in-sync/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the tip! Although I need to shuffle things around to move the auto-generated Sourcery comments after the header anyways, so it doesn't really help in my case.

);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which sourcery >/dev/null; then\n make sourcery\nelse\n echo \"Sourcery not found, install with 'brew install sourcery'\"\nfi";
Copy link
Collaborator

@marcelofabri marcelofabri Jun 2, 2017

Choose a reason for hiding this comment

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

I know these are minor issues, but:

  1. Shouldn't we avoid running sourcery on CI?
  2. What do you think about making this message a warning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Travis doesn't appear to have Sourcery installed.
  2. It shouldn't be an error (or a warning even) if you don't have Sourcery installed but you're building SwiftLint via Xcode. It's only really useful for contributors.

Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Feel free to merge it 🎉

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, just fixing up the merge conflict now.

jpsim added 4 commits June 2, 2017 14:28
This adds 6 tests that were accidentally not being run on Linux:

* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresComments
* LineLengthConfigurationTests.testLineLengthConfigurationInitialiserSetsIgnoresFunctionDeclarations
* LineLengthConfigurationTests.testLineLengthConfigurationThrowsOnBadConfigValues
* LineLengthRuleTests.testLineLengthWithIgnoreCommentsEnabled
* LineLengthRuleTests.testLineLengthWithIgnoreFunctionDeclarationsEnabled
* RegionTests.testSeveralRegionsFromSeveralCommands
only runs if Sourcery is installed.
@jpsim jpsim force-pushed the jp-sourcery-master-rule-list branch 2 times, most recently from ba05793 to 922a867 Compare June 2, 2017 22:02
@jpsim jpsim merged commit 6712b54 into master Jun 2, 2017
@jpsim jpsim deleted the jp-sourcery-master-rule-list branch June 2, 2017 22:02
@codecov-io
Copy link

Codecov Report

Merging #1592 into master will increase coverage by 3.66%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1592      +/-   ##
==========================================
+ Coverage   84.35%   88.02%   +3.66%     
==========================================
  Files         193      193              
  Lines       10081     9661     -420     
==========================================
  Hits         8504     8504              
+ Misses       1577     1157     -420
Impacted Files Coverage Δ
...Tests/CyclomaticComplexityConfigurationTests.swift 100% <ø> (+15.66%) ⬆️
Tests/SwiftLintFrameworkTests/CommandTests.swift 100% <ø> (+10.97%) ⬆️
...rkTests/ImplicitlyUnwrappedOptionalRuleTests.swift 100% <ø> (+25%) ⬆️
...wiftLintFrameworkTests/ExtendedNSStringTests.swift 93.75% <ø> (+22.32%) ⬆️
...iftLintFrameworkTests/RuleConfigurationTests.swift 91.83% <ø> (+14.25%) ⬆️
.../SwiftLintFrameworkTests/LineLengthRuleTests.swift 100% <ø> (+10.2%) ⬆️
.../SwiftLintFrameworkTests/Yaml+SwiftLintTests.swift 84.84% <ø> (+9.17%) ⬆️
Tests/SwiftLintFrameworkTests/ColonRuleTests.swift 100% <ø> (+4.28%) ⬆️
Tests/SwiftLintFrameworkTests/RuleTests.swift 84.61% <ø> (+23.5%) ⬆️
...ts/SwiftLintFrameworkTests/TypeNameRuleTests.swift 100% <ø> (+12.24%) ⬆️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2ef118...922a867. Read the comment docs.

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.

5 participants