-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Reenable cache #1530
Conversation
…files with a weak algorithm.
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
Generated by 🚫 danger |
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
"root": rootPath ?? FileManager.default.currentDirectoryPath, | ||
"rules": cacheRulesDescriptions | ||
] | ||
if let jsonData = try? JSONSerialization.data(withJSONObject: dict), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 Set
s. In this particular case, it'd be probably even better for the user if we always sorted the Set
s. Or even don't use them at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
🎉 |
Significantly extended from #1516 /cc @victorpimentel @marcelofabri