Skip to content

Check unused imports#1204

Open
JaewonHur wants to merge 3 commits intoapple:mainfrom
JaewonHur:check-unused-import
Open

Check unused imports#1204
JaewonHur wants to merge 3 commits intoapple:mainfrom
JaewonHur:check-unused-import

Conversation

@JaewonHur
Copy link
Contributor

Add scripts/check-unused-imports.sh which checks the unused imports in modified swift source files.
Good to be used before making a pull request after modifying or creating lots of swift source files.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

Developers can check and refine unused imports using this script, before making a PR.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

@echo Building container binaries...
@$(SWIFT) --version
@$(SWIFT) build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION)
@$(SWIFT) build -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) $(BUILD_OPTIONS)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure it's a good approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

For the pre-commit hook I added a separate swift-format config file for format-only checking. Could we use swift format in lint mode to do this, and then perhaps it's just a matter of adjusting the existing lint rule file?

swift-fmt-check:
	@echo Applying the standard code formatting...
	@$(SWIFT) format lint --recursive --strict --configuration .swift-format-nolint $(SWIFT_SRC)

@saehejkang
Copy link
Contributor

Thoughts on updating the make fmt command to run this script? Maybe even the possibility of it making the formatting changes, ie. actually remove the unused imports?

@JaewonHur
Copy link
Contributor Author

Hi @saehejkang I'm not sure it might be merged to make fmt :)
It requires rebuilding the project with verbose flag, which is quite slow.

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.

3 participants