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

Reenable cache #1530

Merged
merged 18 commits into from
May 22, 2017
Merged

Reenable cache #1530

merged 18 commits into from
May 22, 2017

Conversation

jpsim
Copy link
Collaborator

@jpsim jpsim commented May 18, 2017

Significantly extended from #1516 /cc @victorpimentel @marcelofabri

victorpimentel and others added 16 commits May 18, 2017 13:39
applying minor edits.

Remove `configurationDescription` from breaking changes
in changelog since additions aren't breaking changes.
rather than use hardcoded, duplicate string literals
rather than just when using one of many code paths in one of many
initializers
to provide more complete descriptions for cache invalidation
purposes.
by respecting the value of ignoreCache rather than always passing 'true'
to make the cache play nicely with nested configurations
and make cacheURL an internal member of Configuration
@jpsim jpsim requested a review from marcelofabri May 18, 2017 22:03
@jpsim jpsim mentioned this pull request May 18, 2017
@SwiftLintBot
Copy link

SwiftLintBot commented May 18, 2017

1 Warning
⚠️ Big PR
12 Messages
📖 Linting WordPress with this PR took 9.41s vs 12.37s on master (23% faster)
📖 Linting Alamofire with this PR took 2.27s vs 2.39s on master (5% faster)
📖 Linting Firefox with this PR took 9.62s vs 10.15s on master (5% faster)
📖 Linting Kickstarter with this PR took 12.64s vs 13.74s on master (8% faster)
📖 Linting Moya with this PR took 0.31s vs 0.33s on master (6% faster)
📖 Linting Nimble with this PR took 1.25s vs 1.33s on master (6% faster)
📖 Linting Aerial with this PR took 0.35s vs 0.36s on master (2% faster)
📖 Linting Realm with this PR took 1.95s vs 1.99s on master (2% faster)
📖 Linting SourceKitten with this PR took 0.83s vs 0.86s on master (3% faster)
📖 Linting Sourcery with this PR took 2.02s vs 2.09s on master (3% faster)
📖 Linting Swift with this PR took 8.94s vs 9.65s on master (7% faster)
📖 Linting Quick with this PR took 0.42s vs 0.43s on master (2% faster)

Generated by 🚫 danger

@codecov-io
Copy link

codecov-io commented May 18, 2017

Codecov Report

Merging #1530 into master will increase coverage by 0.78%.
The diff coverage is 78.37%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1530      +/-   ##
==========================================
+ Coverage   82.78%   83.57%   +0.78%     
==========================================
  Files         187      186       -1     
  Lines        9342     9547     +205     
==========================================
+ Hits         7734     7979     +245     
+ Misses       1608     1568      -40
Impacted Files Coverage Δ
...Framework/Extensions/NSFileManager+SwiftLint.swift 70.58% <0%> (-9.42%) ⬇️
...s/SwiftLintFrameworkTests/ConfigurationTests.swift 81.73% <0%> (-0.8%) ⬇️
Source/swiftlint/Commands/LintCommand.swift 0% <0%> (ø) ⬆️
...iftlint/Extensions/Configuration+CommandLine.swift 0% <0%> (ø) ⬆️
...iftLintFramework/Protocols/RuleConfiguration.swift 50% <0%> (-50%) ⬇️
...SwiftLintFramework/Rules/PrivateUnitTestRule.swift 87.5% <100%> (+0.46%) ⬆️
Source/SwiftLintFramework/Rules/CustomRules.swift 98.11% <100%> (+0.15%) ⬆️
Source/SwiftLintFramework/Protocols/Rule.swift 100% <100%> (+12.5%) ⬆️
...s/RuleConfigurations/AttributesConfiguration.swift 65.21% <100%> (+17.39%) ⬆️
...k/Rules/RuleConfigurations/NameConfiguration.swift 97.77% <100%> (+13.33%) ⬆️
... and 20 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 9b8bde9...cea6f43. Read the comment docs.

"root": rootPath ?? FileManager.default.currentDirectoryPath,
"rules": cacheRulesDescriptions
]
if let jsonData = try? JSONSerialization.data(withJSONObject: dict),
Copy link
Collaborator

Choose a reason for hiding this comment

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

AFAIK, the json string created by JSONSerialization is non-deterministic in dictionary key order on Linux.
Should we consider something about 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.

None of this relies on key order remaining stable.

Copy link
Collaborator Author

@jpsim jpsim May 19, 2017

Choose a reason for hiding this comment

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

Oh, yes it does of course. The cache.json file doesn't rely on ordering, but since this is embedded as a string, that does matter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What do you mean though that the order is non-deterministic?

Copy link
Collaborator

Choose a reason for hiding this comment

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

configuration.cacheDescription is used for key to getting cache in cache(violations:forFile:configuration:) and violations(forFile:configuration:).
cacheDescription is jsonstring serialized by JSONSerialization.
So, getting cache depends on non-deterministic string keys.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yup. The fact that the result is always constant with macOS is just such an implementation, it is not guaranteed as a specification.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But actually, do we use Set here? Or just Dictionary?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Configuration.cacheDescription > Rule.cacheDescription > RuleConfiguration.consoleDescription > https://github.com/realm/SwiftLint/blob/master/Source/SwiftLintFramework/Rules/RuleConfigurations/AttributesConfiguration.swift#L13-L20

Copy link
Collaborator

Choose a reason for hiding this comment

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

🤔

We could revisit those consoleDescription to avoid using Sets. In this particular case, it'd be probably even better for the user if we always sorted the Sets. Or even don't use them at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Took a stab at fixing this in 0c09520 & cea6f43.

@jpsim
Copy link
Collaborator Author

jpsim commented May 22, 2017

Will merge. We should do a prerelease of SwiftLint with this and all the many other changes to make sure it doesn't break things in the wild since there's so much.

@jpsim jpsim merged commit 572754f into master May 22, 2017
@jpsim jpsim deleted the jp-reenable-cache-v2 branch May 22, 2017 05:43
@marcelofabri
Copy link
Collaborator

🎉

@jpsim
Copy link
Collaborator Author

jpsim commented May 22, 2017

0.19.0-rc.1

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.

7 participants