Skip to content

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

Description

@jecisc

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 

Activity

  1. added this to the v1.1.x milestone on Apr 22, 2020
  2. modified the milestones: v1.1.x, v1.x.x on May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions