You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have an issue with the latest version of SwiftLint and it seems as though it is because of a bug with SourceKitten itself. This has only manifested since updating to the latest version of SwiftLint, which is also using the latest version of SourceKitten.
SourceKitten does not report any substructure for the setUp() function, despite containing valid code in there.
More info
I've put together a test case which shows the issue:
func testBug()throws{letcontents="class TotoTests: XCTestCase {\n var foo: String = \"\"\n override func setUp() {\n foo = \"bar\"\n }\n}"letstructure=tryStructure(file:.init(contents: contents))letsubstructureArray=tryXCTUnwrap(structure.dictionary["key.substructure"]as?[SourceKitRepresentable])letsubstructureDictionary=tryXCTUnwrap(substructureArray.first as?[String:SourceKitRepresentable])lettypeName=tryXCTUnwrap(substructureDictionary["key.name"]as?String)XCTAssertEqual(typeName,"TotoTests")lettypeSubstructureArray=tryXCTUnwrap(substructureDictionary["key.substructure"]as?[SourceKitRepresentable])XCTAssertEqual(typeSubstructureArray.count,2)// Only has one property and one functionletpropertySubstructureDictionary=tryXCTUnwrap(typeSubstructureArray[0]as?[String:SourceKitRepresentable])letpropertyName=tryXCTUnwrap(propertySubstructureDictionary["key.name"]as?String)XCTAssertEqual(propertyName,"foo")letfunctionSubstructureDictionary=tryXCTUnwrap(typeSubstructureArray[1]as?[String:SourceKitRepresentable])letfunctionName=tryXCTUnwrap(functionSubstructureDictionary["key.name"]as?String)XCTAssertEqual(functionName,"setUp()")letfunctionContentsArray=tryXCTUnwrap(functionSubstructureDictionary["key.substructure"]as?[SourceKitRepresentable])XCTAssertEqual(functionContentsArray.count,1)}
Just to validate, if you change the contents to this:
letcontents="class TotoTests: XCTestCase {\n var foo: String = \"\"\n override func setUp() {\n let foo = \"bar\"\n }\n}"
Then the test passes fine. It's only an issue when setting an instance variable, rather than a local variable:
I hope this helps debug, I don't know much more about SourceKitten but I can try and take a look at fixing too, but raising here because likely the code owner(s) will be able to fix it faster :)
The text was updated successfully, but these errors were encountered:
The Structure API in SourceKitten makes a single query to SourceKit, source.request.editor.open, and returns the doc structure results without modification. You could check on the Swift nightly toolchain: if it's still a problem then the question -- something like "Assignment expressions missing from doc structure' belongs with the Swift project.
Right -- just for interest, notice there you get just a source.lang.swift.expr.call inside the substructure which is the String() part -- the assignment part itself is not mentioned.
We have an issue with the latest version of SwiftLint and it seems as though it is because of a bug with SourceKitten itself. This has only manifested since updating to the latest version of SwiftLint, which is also using the latest version of SourceKitten.
TL;DR:
When provided with the following code:
SourceKitten does not report any substructure for the setUp() function, despite containing valid code in there.
More info
I've put together a test case which shows the issue:
Just to validate, if you change the
contents
to this:Then the test passes fine. It's only an issue when setting an instance variable, rather than a local variable:
Additionally a similar issue was raised on the SwiftLint repo which I believe to be because of the same issue in SourceKitten.
I hope this helps debug, I don't know much more about SourceKitten but I can try and take a look at fixing too, but raising here because likely the code owner(s) will be able to fix it faster :)
The text was updated successfully, but these errors were encountered: