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

Feature/blt phpcbf #1019

Merged
merged 6 commits into from
Mar 9, 2017
Merged

Feature/blt phpcbf #1019

merged 6 commits into from
Mar 9, 2017

Conversation

dooleymatt
Copy link
Contributor

Fixes # 977.

Changes proposed:

  • Adds fix:phpcbf target to automatically fix violations found by phpcs.

@dooleymatt
Copy link
Contributor Author

@grasmash this is ready to be reviewed. What action should I take to indicate that?

@grasmash grasmash added the Enhancement A feature or feature request label Jan 31, 2017
@grasmash
Copy link
Contributor

@dooleymatt Please add a test for this feature. Ideally, you should have a tests that asserts both positive and negative cases.

@dooleymatt
Copy link
Contributor Author

Thanks @grasmash. I took a look at the existing tests to see how to write one for this, but I'm not really sure what I should I be testing. It seems like most of the existing tests check for files that have been added, removed, or changed, but I'm not sure what similar tests could be performed for this new task. I am hoping either you or @TravisCarden could offer some direction. Thanks!

@TravisCarden
Copy link
Contributor

I'd be happy to chat about it, @dooleymatt.

@dooleymatt dooleymatt force-pushed the feature/blt-phpcbf branch 3 times, most recently from 9281b6f to 18916bc Compare March 2, 2017 21:22
@dooleymatt
Copy link
Contributor Author

@grasmash Test has been added.

Copy link
Contributor

@TravisCarden TravisCarden left a comment

Choose a reason for hiding this comment

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

I think at least one important unit test is missing: one that starts by writing a dummy file with fixable coding standards violations in it, runs the PHCBF script on it, and then asserts that the coding standards violations are fixed.

throw new \Exception("Unable to create temporary file.");
}
$file_contents = "\"{$this->projectDirectory}/docroot/foo.php\",1,1,error,\"Line indented incorrectly; expected 2 spaces, found 4\",Drupal.WhiteSpace.ScopeIndent.IncorrectExact,5,1";
$command = "echo '$file_contents' > {$tmp_file}";
Copy link
Contributor

Choose a reason for hiding this comment

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

@dooleymatt file_put_contents() would be simpler, since we're writing PHP. (I realize I put you on the wrong scent by using the word "echo".)

}

/**
* Helper method that xecutes the phpcbf-file-list.sh script.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: "xecutes".

* Tests that a file list is generated.
*/
public function testFixPhpcbfWithArguments() {
$report = $this->createTestReport();
Copy link
Contributor

Choose a reason for hiding this comment

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

@dooleymatt I'm confused: Don't you want to be creating a test file rather than a test report? A PHP file with standards violations in it so you can assert that PHPCBF correctly finds it?

@dooleymatt dooleymatt force-pushed the feature/blt-phpcbf branch from 18916bc to 583ce73 Compare March 6, 2017 23:47
@dooleymatt
Copy link
Contributor Author

@TravisCarden Thanks for reviewing this. I initially didn't include a test like you described because I felt like it might have been outside the scope of this to test whether or not phpcbf actually does what it's supposed to do. However, I've updated the test to include that now, and have also updated the way that the phpcs csv file report is generated.

@grasmash
Copy link
Contributor

grasmash commented Mar 9, 2017

@dooleymatt This looks great. My only request is that we put this in the validate: namespace rather than creating a new fix: namespace.

@dooleymatt
Copy link
Contributor Author

@grasmash I based that change on Travis's request here: #977 (comment)

@grasmash
Copy link
Contributor

grasmash commented Mar 9, 2017

Eh, alright. The argument makes sense.

@grasmash grasmash merged commit 771a11a into acquia:8.x Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement A feature or feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants