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

Use udiff format for php-cs-fixer diff output #31484

Merged
merged 1 commit into from
May 23, 2018

Conversation

phil-davis
Copy link
Contributor

Description

Use the udiff format when logging diffs of php-cs-fixer code style fixes.

Related Issue

Motivation and Context

Currently php-cs-fixer uses a diff output format that:

  1. does not provide line numbers (making it more annoying when trying to find the problem place in the code)
  2. outputs contents of the whole file after the point of the first diff (making the output annoying long)

These days there is a --diff-format udiff option which provides a diff that solves the above issues, and looks a lot more like the diff that developers will be used to seeing for patches etc.

How Has This Been Tested?

Make some rubbish changes to code, then run:

make test-php-style

and see more compact diff output.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Test/code quality infrastructure

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov
Copy link

codecov bot commented May 20, 2018

Codecov Report

Merging #31484 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #31484   +/-   ##
=========================================
  Coverage      62.6%    62.6%           
  Complexity    18271    18271           
=========================================
  Files          1147     1147           
  Lines         68621    68621           
  Branches       1234     1234           
=========================================
  Hits          42963    42963           
  Misses        25297    25297           
  Partials        361      361
Flag Coverage Δ Complexity Δ
#javascript 52.05% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 63.8% <ø> (ø) 18271 <ø> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 717f041...e309133. Read the comment docs.

@phil-davis
Copy link
Contributor Author

Sample output with udiff

   1) core/Command/App/Enable.php (class_definition, native_function_invocation, braces)
      ---------- begin diff ----------
--- Original
+++ New
@@ -76,7 +76,7 @@
 			$output->writeln($appId . ' enabled');
 		} else {
 			\OC_App::enable($appId, $groups);
-			$output->writeln($appId . ' enabled for groups: ' . implode(', ', $groups));
+			$output->writeln($appId . ' enabled for groups: ' . \implode(', ', $groups));
 		}
 
 		return 0;

      ----------- end diff -----------

   2) core/Command/Group/ListGroupMembers.php (class_definition, braces)
      ---------- begin diff ----------
--- Original
+++ New
@@ -56,7 +56,7 @@
 	protected function execute(InputInterface $input, OutputInterface $output) {
 		$groupName = $input->getArgument('group');
 		$group = $this->groupManager->get($groupName);
-		if(!$group) {
+		if (!$group) {
 			$output->writeln("<error>Group $groupName does not exist</error>");
 			return 1;
 		}

----------- end diff -----------

@DeepDiver1975 DeepDiver1975 merged commit fc8a584 into master May 23, 2018
@DeepDiver1975 DeepDiver1975 deleted the php-cs-fixer-udiff-format branch May 23, 2018 08:23
@phil-davis
Copy link
Contributor Author

This change has been added to backport PR #31453
So it will happen in stable10 some day.

@PVince81 PVince81 modified the milestones: development, QA Jun 13, 2018
@lock
Copy link

lock bot commented Jul 30, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants