Skip to content

Add Rector #2

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

Merged
merged 3 commits into from
Nov 20, 2021
Merged

Add Rector #2

merged 3 commits into from
Nov 20, 2021

Conversation

MGatner
Copy link
Member

@MGatner MGatner commented Nov 18, 2021

No description provided.

@MGatner MGatner requested a review from samsonasik November 18, 2021 23:57
@MGatner
Copy link
Member Author

MGatner commented Nov 18, 2021

@samsonasik See what you think of this. Based on the version from the CI4 repo with the "utility" classes and file references removed. Once PHP 7.4 is the minimum we can update some of these rule sets to be more inclusive.

src/rector.php Outdated

// do you need to include constants, class aliases or custom autoloader? files listed will be executed
$parameters->set(Option::BOOTSTRAP_FILES, [
realpath(getcwd()) . '/vendor/autoload.php',
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

That actually makes me think that we don't need to reference the autoload file at all, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed the Composer path altogether (it seems like Rector finds this on its own) and cleaned the config file up a bunch. Re-review please?


- name: Analyze for refactoring
run: |
composer global require --dev rector/rector:^0.12.4
Copy link
Member

Choose a reason for hiding this comment

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

better to have pinned version so we can verify every version to verify bug fix, like in codeigniter4/CodeIgniter4#5328 (comment)

Suggested change
composer global require --dev rector/rector:^0.12.4
composer global require --dev rector/rector:0.12.4

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure how to handle this one. The goal is for these to be templates that developers can merge into their own repos and then adjust as necessary. I don't want us to have to keep updating this repo every time there is a new minor patch to Rector. Maybe we reference the minor version ^0.12 and add a note to the docs that developers should consider locking it to the specific patch?

Copy link
Member Author

Choose a reason for hiding this comment

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

I rolled it back to the unspecified version and added a note in the docs; see what you think.

@MGatner MGatner requested a review from samsonasik November 19, 2021 14:16
// The paths to refactor (can also be supplied with CLI arguments)
$parameters->set(Option::PATHS, [
__DIR__ . '/app',
__DIR__ . '/tests',
Copy link
Member

Choose a reason for hiding this comment

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

is this not used in CodeIgniter4 project as not check system dir?

Copy link
Member Author

Choose a reason for hiding this comment

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

The intent is not for this to be used in the framework repo but distributable to developer's projects and libraries. Libraries will need to adjust the path from app/ to src/ (or whatever they use), but that is the case for all the files in this repo and I hope to make a scripted solution down the road.

@@ -130,6 +130,9 @@ predefined rulesets. Rector can be highly opinionated based on its configuration
so be sure to read the documentation and figure out the best fit for you. This workflow performs
a "dry run" to check for any changes that Rector would have made and fail if there are matches.

> Note: Rector updates rules all the time so you may want to lock your repo to the latest known working version of Rector to prevent unexpected failures
> E.g. in **.github/workflows/rector.yml** supply the specific minor patch: `composer global require --dev rector/rector:0.12.4`

Copy link
Member

Choose a reason for hiding this comment

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

👍

@MGatner MGatner merged commit 739ba4b into develop Nov 20, 2021
@MGatner MGatner deleted the rector branch November 20, 2021 12:42
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