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

Linting: Only warn when copying the target Info.plist #1203

Merged
merged 3 commits into from Apr 9, 2020

Conversation

sgrgrsn
Copy link
Collaborator

@sgrgrsn sgrgrsn commented Apr 8, 2020

Resolves #1170

Short description πŸ“

When adding a framework (eg. Firebase) that requires you to add a .plist file as a resource Tuist will raise an unnecessary warning about copying an Info.plist file.

While it's still useful to get the warning if you by mistake copy the actual Info.plist file for the target to the resources, I still think we should keep the check as a part of the target linting.

Solution πŸ“¦

Instead of checking all the copied file paths to contain the phrase "Info.plist" we should instead check if the defined Info.plist path on the target is contained in the copied resources.

Implementation πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

  • Reproduce the issue in the TargetLinterTests
  • Adjust the check in lintCopiedFiles in TargetLinter to check if the target's Info.plist path is contained the list of copied files

@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #1203 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1203      +/-   ##
==========================================
+ Coverage   76.61%   76.67%   +0.05%     
==========================================
  Files         291      291              
  Lines       10140    10138       -2     
==========================================
+ Hits         7769     7773       +4     
+ Misses       2371     2365       -6     
Impacted Files Coverage Ξ”
Sources/TuistGenerator/Linter/TargetLinter.swift 97.50% <100.00%> (-0.05%) ⬇️
...ces/TuistGenerator/Generator/ConfigGenerator.swift 97.91% <0.00%> (+3.47%) ⬆️
Sources/TuistSupport/Xcode/XcodeController.swift 86.95% <0.00%> (+4.34%) ⬆️

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 c1fcfed...ba923f7. Read the comment docs.

@sgrgrsn sgrgrsn marked this pull request as ready for review April 9, 2020 07:22
@sgrgrsn
Copy link
Collaborator Author

sgrgrsn commented Apr 9, 2020

I'm not entirely sure why the code coverage has changed (especially in the files I haven't touched). Can somebody help me out? Thanks.

@ollieatkinson ollieatkinson requested review from a team and pepicrft and removed request for a team April 9, 2020 08:27
Copy link
Collaborator

@ollieatkinson ollieatkinson left a comment

Choose a reason for hiding this comment

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

Great contribution!

let reason = "Info.plist at path \($0.pathString) being copied into the target \(target.name) product."
return LintingIssue(reason: reason, severity: .warning)
})
if let targetInfoPlistPath = target.infoPlist?.path, files.contains(targetInfoPlistPath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm inclined towards removing the check. Here's my why:

  • This logic might need to traverse a large list of files. I don't think it'll be a lot if we compare the time that takes with the total generation time, but every bit of time we add aggregates to the other bits.
  • This is a check that Xcode runs early in the process, so it's a bit redundant. Also I think that the error that Xcode surfaces is very obvious, so I don't think we are adding much value from our end.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd be still inclined to keep it because you may write some globs which accidentally include your Info.plist file ... without you knowing.

If we are concerned about performance we can use a Set which is O(1) for contains - but I really don't think that it's worth it right now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave it then. If we see this becomes a performance bottleneck, we can either move those attributes to sets, or consider running linters in parallel, considering that they are not doing permutations of the models.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good point. I didn't know about the Xcode warning since I've never tried to add the Info.plist to the resources. I'm fine with removing it πŸ‘

Should I just go ahead and do it or is it something that has to be discussed further? @olejnjak mentioned on the issue that he thinks the warning is quite nice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I didn't see your replies. Just forget my comment πŸ˜ƒ

@pepicrft pepicrft merged commit f28fa96 into tuist:master Apr 9, 2020
@pepicrft
Copy link
Contributor

pepicrft commented Apr 9, 2020

Congrats on your first contribution @sgrgrsn! You rock πŸš€

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.

Unwanted warning about Info.plist files added as resources
3 participants