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

Code being reformatted poorly #380

Open
slightlyfaulty opened this issue Dec 23, 2019 · 1 comment
Open

Code being reformatted poorly #380

slightlyfaulty opened this issue Dec 23, 2019 · 1 comment

Comments

@slightlyfaulty
Copy link

slightlyfaulty commented Dec 23, 2019

🐞 bug report

Behavior:

  • What is the issue? (*)

    Any file that is modified with the pre-processor is completely and badly reformatted.
  • What is the expected behavior?

    Only code related to the SDK should be changed. Formatting of all code in the file should not be completely changed and reformatted to have things like double spaces and spaces before semi-colons.

For example, code goes from this:

<?php
/**
 * Plugin Name: ...
 */

defined('ABSPATH') or die;

const PLUGIN_VERSION = '1.0.0';

require_once __DIR__ . '/includes.php';

Plugin::run();

if (plugin_fs()->is__premium_only()) {
    $test = 123;
} else {
    $test = 456;
}

to this (all line breaks removed, random spaces added, extra line break at top of file):

<?php

/**
 * Plugin Name: ...
 */
defined( 'ABSPATH' ) or die;
const  PLUGIN_VERSION = '1.0.0' ; // <-- two extra spaces added here
require_once __DIR__ . '/includes.php';
Plugin::run();
$test = 456;

It looks much worse when you have a lot more code. And the same happens with classes, e.g. no line break between use and class, properties and methods, etc.

This really negatively impacts the overall quality of the plugin's code. It's difficult to read and looks like the developer didn't give a damn writing it. I really hope this can be looked into at some point. I certainly will not be releasing code that looks like this.

@vovafeldman
Copy link
Contributor

The PHP Parser library that we currently use doesn't yet have a stable format-preserving prettifier, that's why you see the code style changes (only) in files that require editing by the preprocessor. That said, they are working on that and we keep track of the changes. Once they'll have a stable version we'll update the preprocessor to work with that version.

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

2 participants