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

Incorrect warning: duplicate element id #170

Closed
wata opened this issue May 11, 2021 · 12 comments · Fixed by #172
Closed

Incorrect warning: duplicate element id #170

wata opened this issue May 11, 2021 · 12 comments · Fixed by #172

Comments

@wata
Copy link

wata commented May 11, 2021

IBlinter says SignIn.storyboard:0:0: warning: duplicate element id 9SU-qi-UFm. But in fact, there is only one element whose id is 9SU-qi-UFm . Is this the expected behavior?

Version: 0.4.26
Using: Homebrew and CocoaPods - same result for both
.iblinter.yml:

enabled_rules:
  - misplaced
  - view_as_device
  - image_resources
excluded:
  - Pods
view_as_device_rule:
  device_id: retina5_9

Search Results for 9SU-qi-UFm :

  • <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" usesAttributedText="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9SU-qi-UFm">
  • <constraint firstItem="9SU-qi-UFm" firstAttribute="leading" secondItem="L3f-4j-PFL" secondAttribute="leading" id="TtQ-0E-1RQ"/>
  • <constraint firstItem="9SU-qi-UFm" firstAttribute="centerX" secondItem="L3f-4j-PFL" secondAttribute="centerX" id="Y9A-8a-Q6E"/>
  • <constraint firstItem="9SU-qi-UFm" firstAttribute="centerY" secondItem="L3f-4j-PFL" secondAttribute="centerY" id="cnK-2q-oAm"/>
  • <constraint firstAttribute="trailing" secondItem="9SU-qi-UFm" secondAttribute="trailing" id="gxV-NN-gNj"/>
  • <outlet property="descriptionsTextView" destination="9SU-qi-UFm" id="ar7-62-iKJ"/>

I have tried DuplicateIDRuleTests with the latest version of the source code, but it seems to be failing.

Test Suite 'DuplicateIDRuleTests' started at 2021-05-11 16:55:32.057
Test Case '-[IBLinterKitTest.DuplicateIDRuleTests testDuplicateId]' started.
/Users/wata/tmp/IBLinter/Tests/IBLinterKitTest/Rules/DuplicateIDRuleTests.swift:20: error: -[IBLinterKitTest.DuplicateIDRuleTests testDuplicateId] : XCTAssertEqual failed: ("5") is not equal to ("2")
/Users/wata/tmp/IBLinter/Tests/IBLinterKitTest/Rules/DuplicateIDRuleTests.swift:22: error: -[IBLinterKitTest.DuplicateIDRuleTests testDuplicateId] : XCTAssertEqual failed: ("["duplicate element id fullscreen", "duplicate element id iN0-l3-epB", "duplicate element id aEU-56-OK8", "duplicate element id fullscreen", "duplicate element id fullscreen"]") is not equal to ("["duplicate element id iN0-l3-epB", "duplicate element id aEU-56-OK8"]")
Test Case '-[IBLinterKitTest.DuplicateIDRuleTests testDuplicateId]' failed (0.772 seconds).
Test Suite 'DuplicateIDRuleTests' failed at 2021-05-11 16:55:32.829.
	 Executed 1 test, with 2 failures (0 unexpected) in 0.772 (0.772) seconds
@phimage
Copy link
Member

phimage commented May 11, 2021

I launch the DuplicateIDRuleTests and no issue for me
(Xcode 12.4)

@wata
Copy link
Author

wata commented May 12, 2021

Thanks for checking. It's still a failure for me (Xcode 12.5)
スクリーンショット 2021-05-12 13 43 30

@mt-hodaka
Copy link

I’m having same issue and get same result as #170 (comment)

@kateinoigakukun
Copy link
Collaborator

kateinoigakukun commented May 24, 2021

Sorry for my slow response 🙇
Hmm, I couldn't reproduce the test failure in my local environment (w/Xcode12.5).

@wata Could you share your storyboard file facing this issue?

@phimage
Copy link
Member

phimage commented May 24, 2021

I test again, Xcode 12.5, IBDecodable version to 0.4.0 or 0.4.2 and no issue

@wata
Copy link
Author

wata commented May 24, 2021

Thanks for your response. This is the actual file.
SignIn.storyboard.zip

@kateinoigakukun
Copy link
Collaborator

@wata Thank you! However I couldn't reproduce the incorrect warning... 😢

What I tried is below. I tried this for master revision and the latest distributed version.

$ ls -a
.iblinter.yml
SignIn.storyboard
$ cat .iblinter.yml
enabled_rules:
  - misplaced
  - view_as_device
  - image_resources
excluded:
  - Pods
view_as_device_rule:
  device_id: retina5_9

$ iblinter version
0.4.26
$ iblinter
/private/var/folders/br/7sr_p7cj7v549x_gtkb33df00000gp/T/tmp.ImklW2ND/SignIn.storyboard:0:0: error: appIcon_blue not found

@wata
Copy link
Author

wata commented May 24, 2021

My result:

$ ls -a
.iblinter.yml
SignIn.storyboard

$ cat .iblinter.yml
enabled_rules:
  - misplaced
  - view_as_device
  - image_resources
excluded:
  - Pods
view_as_device_rule:
  device_id: retina5_9

$ iblinter version
0.4.26

$ iblinter
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id iYo-8I-qsd
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 7jp-cj-Jfa
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id E8n-kU-Q5C
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id L4O-JP-FdO
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Pnf-U7-Bf2
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id h6f-C9-KfF
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id nLy-az-dV5
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id oWg-9E-n1j
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id vQt-en-xID
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Nua-db-AEm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id JQk-rB-6c4
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id ugH-V1-KiJ
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id DBz-aR-sRp
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id OJa-3Q-x62
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 4qb-fh-kEd
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id vUP-Il-T7s
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id IfF-Ux-ccf
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id aUY-ad-dXj
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id L3f-4j-PFL
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 8fl-6F-IT8
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 8tB-gl-Bzn
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id TtQ-0E-1RQ
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Y9A-8a-Q6E
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id cnK-2q-oAm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id gxV-NN-gNj
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 9SU-qi-UFm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 94x-Bh-O82
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id iYo-8I-qsd
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 7jp-cj-Jfa
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id E8n-kU-Q5C
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id L4O-JP-FdO
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Pnf-U7-Bf2
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id h6f-C9-KfF
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id nLy-az-dV5
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id oWg-9E-n1j
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id vQt-en-xID
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Nua-db-AEm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id JQk-rB-6c4
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id ugH-V1-KiJ
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id DBz-aR-sRp
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id OJa-3Q-x62
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 4qb-fh-kEd
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id vUP-Il-T7s
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id IfF-Ux-ccf
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id aUY-ad-dXj
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id L3f-4j-PFL
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 8fl-6F-IT8
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 8tB-gl-Bzn
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id TtQ-0E-1RQ
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Y9A-8a-Q6E
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id cnK-2q-oAm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id gxV-NN-gNj
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 9SU-qi-UFm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id ar7-62-iKJ
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id iYo-8I-qsd
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 7jp-cj-Jfa
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id E8n-kU-Q5C
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id L4O-JP-FdO
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Pnf-U7-Bf2
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id h6f-C9-KfF
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id nLy-az-dV5
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id oWg-9E-n1j
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id vQt-en-xID
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Nua-db-AEm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id JQk-rB-6c4
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id ugH-V1-KiJ
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id DBz-aR-sRp
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id OJa-3Q-x62
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 4qb-fh-kEd
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id vUP-Il-T7s
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id IfF-Ux-ccf
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id aUY-ad-dXj
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id L3f-4j-PFL
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 8fl-6F-IT8
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 8tB-gl-Bzn
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id TtQ-0E-1RQ
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id Y9A-8a-Q6E
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id cnK-2q-oAm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id gxV-NN-gNj
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id 9SU-qi-UFm
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: warning: duplicate element id retina5_9
/Users/wata/tmp/2021-05-24/SignIn.storyboard:0:0: error: appIcon_blue not found

@kateinoigakukun
Copy link
Collaborator

kateinoigakukun commented May 24, 2021

@wata
OK, I could reproduce this problem with Docker. (yeah, but it's not still reproduced on my macOS 😅 )

I'll investigate this more. Thanks for your report!

FROM swift:5.4.0

WORKDIR /Workspace
RUN git clone https://github.com/IBDecodable/IBLinter.git .
RUN swift build
RUN swift test

BTW could you tell me your OS version? In different versions of macOS, Swift uses different runtime, so it may be related.
My macOS is 11.2.3 (20D91).

@wata
Copy link
Author

wata commented May 24, 2021

Thank you for investigating. My macOS is 11.3 (20E232).

@kateinoigakukun
Copy link
Collaborator

I got the reason for this problem.

Context of Swift changes

Swift 5.4 has a new dynamic-cast implementation rewritten from 5.3's one. This re-implementation includes refactoring and bug fixes, so there are some different behavior from 5.3.
The difference is described in here

According to the document, SR-1999 is fixed from Swift 5.4.

And the new implementation is shipped as a part of the Swift runtime library in macOS11.3.

SR-1999: Cannot cast Any contents to a protocol type

protocol P {}
class Foo: P {}
let optionalFoo: Foo? = Foo()
let any: Any = optionalFoo
// Swift 5.3: Prints "false"
// Specification: prints "true"
print(any as? P)

IBLinter implementation

We have a part that depends on the incorrect cast behavior of SR-1999 in Swift 5.3.
https://github.com/IBDecodable/IBDecodable/blob/4cce9b9e864ee924be62d45b6d971218c90bba52/Sources/IBProtocol.swift#L239-L250

Even compiling the code with Swift 5.3 compiler, the new cast implementation reveals our wrong implementation on macOS11.3 because Swift uses the runtime library of not compiler-toolchain's one but the running OS's one.

This is why I couldn't reproduce this issue on macOS 11.2.3, and your macOS 11.3 reveals this.

I'll fix this issue this week.

@phimage
Copy link
Member

phimage commented May 24, 2021

well done

PR on IBDecodable merged

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 a pull request may close this issue.

4 participants