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

IB connection rule #9

Closed
wants to merge 15 commits into from
Closed

IB connection rule #9

wants to merge 15 commits into from

Conversation

kateinoigakukun
Copy link
Collaborator

@kateinoigakukun kateinoigakukun commented Jan 12, 2018

Rule description

Check unimplemented outlets and actions in classes.

#5

@@ -5,7 +5,7 @@
// Created by SaitoYuta on 2017/12/13.
//

public protocol InterfaceBuilderFile {
public protocol FileProtocol {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to analyze not only xib or storyboard but also swift

func validate(storyboard: StoryboardFile) -> [Violation]
func validate(xib: XibFile) -> [Violation]
func validate(storyboard: StoryboardFile, swiftParser: SwiftIBParser) -> [Violation]
func validate(xib: XibFile, swiftParser: SwiftIBParser) -> [Violation]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

for swift file

@Sherlouk
Copy link

Had a quick glance and I'm really excited that you've decided to pick this up! Thanks for that!

Looking forward to giving it a go!

@kateinoigakukun
Copy link
Collaborator Author

@Sherlouk I have implemented this feature almost.
Could you review this pull request or build this branch on local and execute ?

@kateinoigakukun kateinoigakukun changed the title [wip] IB connection rule IB connection rule Jan 13, 2018
@Sherlouk
Copy link

Sherlouk commented Jan 13, 2018

Currently getting this when running in my primary project:

fatal error: parse error ~/Projects/.../MainWindow.xib: XML Element Error: Incorrect key ["document"]: file ~/Projects/IBLinter/Sources/IBLinterCore/XibFile.swift, line 37
Illegal instruction: 4

The Xib in question is part of one our dependencies, and I think by looking at the syntax it's a super old version of the format and just hasn't been updated. - I wonder in this eventuality if you could put a warning on the file saying it's an unsupported type or something? (Prompting the user to exclude it or update it)

I've added a configuration file, and excluded the dependencies folder as we wouldn't want to test those - it did a successful run after that but raised a substantial amount of warnings/errors and I've checked a number of them and they appear to be false-positives (they do have a connection)

I'm struggling to follow the code via GH (haven't got time at the moment for a deep review) but I wonder if it has something to do with how you locate corresponding files? Our XIBS are in a different folder than the actual View classes - could this be an issue?

@kateinoigakukun
Copy link
Collaborator Author

kateinoigakukun commented Jan 15, 2018

@Sherlouk Sorry for my late reply.
Your first error seems to be caused for macOS xib file. I'll add file's deployment target validator in another PR.
And your second errors are caused by UITableViewCell and UIBarButtonItem parsing error. I've fixed them. Could you try to check this rule works well?

@Sherlouk
Copy link

Just pulled down, rebuilt and run against and am getting all the same errors!

I'm obviously not dismissing the idea that there are errors among the masses that have been listed, but of the few I've manually checked they do exist. Example of what's being printed:

/~/Projects/.../Web.storyboard::: error: IBOutlet missing: closeButton is not connected
~/Projects/.../Web.storyboard::: error: IBAction missing: closeTapped: is not connected

For what it's worth, 90% of the errors appear to be on storyboards?

@Sherlouk
Copy link

Sherlouk commented Jan 15, 2018

image

image

/~/Projects/.../WebViewToolbar.xib::: error: IBAction missing: closeTapped: is not connected
/~/Projects/.../WebViewToolbar.xib::: error: IBAction missing: forwardTapped: is not connected
/~/Projects/.../WebViewToolbar.xib::: error: IBAction missing: refreshTapped: is not connected
/~/Projects/.../WebViewToolbar.xib::: error: IBAction missing: backTapped: is not connected

Another example where they're definitely connected, but script is saying otherwise!

@kateinoigakukun
Copy link
Collaborator Author

kateinoigakukun commented Jan 20, 2018

@Sherlouk I've added UnknownView struct for parsing any view xml. And your errors will be fixed.
If you couldn't fix, could you send me storyboard file and swift file?

@Sherlouk
Copy link

So first off I'm getting these unsupported views:

  • unsupported view class 'visualEffectView'
  • unsupported view class 'collectionReusableView'
  • unsupported view class 'pageControl'
  • unsupported view class 'activityIndicatorView'
  • unsupported view class 'progressView'
  • unsupported view class 'containerView'

I'm also getting the exact same errors as listed above, I'll do a little bit of digging and see if I can reproduce on a smaller scale (I'm unable to share as is)

@Sherlouk
Copy link

Archive.zip

Had to make some minor changes, but dropped into a clean project it's still failing on these! (It's failing on others but hoping fixing one will fix others!)

@kateinoigakukun
Copy link
Collaborator Author

Bugs have been fixed for the files you sent me.
I can’t thank you enough!

@Sherlouk
Copy link

So this is also having issues when you have multiple xibs in the same project (in different targets though, not sure if there's a way to work that out easily)

All remaining issues are on storyboards only

Archive.zip

@kateinoigakukun
Copy link
Collaborator Author

kateinoigakukun commented Jan 24, 2018

@Sherlouk
I changed to parse UIGestureRecognizer. But if xib contains unsupported element (except unknown view), this rule will cause similar issue.
One of this project's goals is parsing xib and storyboard completely. And this project is WIP. This means that we can fix issue when it is happened. So I'll marge this PR if your all issues are fixed. Could you check this works well?

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.

2 participants