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

Add a cleaner to transform a single conditional as last statement as a guard #32

Open
jecisc opened this issue Apr 12, 2020 · 0 comments
Milestone

Comments

@jecisc
Copy link
Owner

jecisc commented Apr 12, 2020

For example, would rewrite

setUp
	super setUp.

	package := RPackageOrganizer default createPackageNamed: 'Package-Test-For-Chanel'.
	extensionPackage := RPackageOrganizer default createPackageNamed: 'ExtensionPackage-Test-For-Chanel'.

	"We only save the formatter if it is not the one used in the tests.
	The reason is that, while debugging a test, if it fails and is rerun, the set up is runned twice and the formatter used in tests will be saved in `previousFormatter`.
	With this guard, we avoid this case."
	RBProgramNode formatterClass = RBSimpleFormatter
		ifFalse: [ previousFormater := RBProgramNode formatterClass.
			RBProgramNode formatterClass: RBSimpleFormatter ]

as

setUp
	super setUp.

	package := RPackageOrganizer default createPackageNamed: 'Package-Test-For-Chanel'.
	extensionPackage := RPackageOrganizer default createPackageNamed: 'ExtensionPackage-Test-For-Chanel'.

	"We only save the formatter if it is not the one used in the tests.
	The reason is that, while debugging a test, if it fails and is rerun, the set up is runned twice and the formatter used in tests will be saved in `previousFormatter`.
	With this guard, we avoid this case."
	RBProgramNode formatterClass = RBSimpleFormatter ifTrue: [ ^ self ].
	previousFormater := RBProgramNode formatterClass.
	RBProgramNode formatterClass: RBSimpleFormatter 
@jecisc jecisc added this to the v1.1.x milestone Apr 22, 2020
@jecisc jecisc modified the milestones: v1.1.x, v1.x.x May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant