Skip to content

Differences when running prettier more than one time over the same file content #1342

@mnunezdm

Description

@mnunezdm

Hello!!

First of all congrats on the native parser solution, just ran it through my entire company code base (7500 files) and went from 1 hour and 10 minutes on the First run to 10 minutes on the native

After running it I found 4 mismatches between the first run (over an 'ugly' file) and the second run (over a 'prettied' file)

Describe your Issue

		{
			"files": "**/*.{cls,trigger,apex}",
			"options": {
				"tabWidth": 4,
				"apexStandaloneParser": "native"
			}
		},

1.1. First run

			REP_obj_casosProductos__c nuevoCasoProducto = new REP_obj_casosProductos__c /*Name = ESDIM_cls_metodosComunes.TEST,*/(
				REP_fld_product__c = equiposMaestro[i].Id,
				REP_fld_caso__c = lstCase[i].Id
			);
			insert nuevoCasoProducto;

1.2. Second run

			REP_obj_casosProductos__c nuevoCasoProducto = new REP_obj_casosProductos__c(
				/*Name = ESDIM_cls_metodosComunes.TEST,*/ REP_fld_product__c = equiposMaestro[
						i
					]
					.Id,
				REP_fld_caso__c = lstCase[i].Id
			);
			insert nuevoCasoProducto;

2.1. First run

						if (
							mapOrderItem.containsKey(
								porder.OrderId
							) /* && mapOrderTank.containsKey(porder.OrderId)*/
						) {
							System.debug('Lo contiene el map de OI');
							mapOrderItem.get(porder.OrderId).add(porder);
							//mapOrderTank.get(porder.OrderId).add(porder.ESESO_fld_nombreTanqueL__c);
						} else {
							System.debug('No lo contiene el mapa de OI');
							mapOrderItem.put(
								porder.OrderId,
								new List<OrderItem>{ porder }
							);
							//mapOrderTank.put(porder.OrderId, new List<Id>{porder.ESESO_fld_nombreTanqueL__c});
						}

2.2. Second run

						if (mapOrderItem.containsKey(porder.OrderId)) {
							/* && mapOrderTank.containsKey(porder.OrderId)*/
							System.debug('Lo contiene el map de OI');
							mapOrderItem.get(porder.OrderId).add(porder);
							//mapOrderTank.get(porder.OrderId).add(porder.ESESO_fld_nombreTanqueL__c);
						} else {
							System.debug('No lo contiene el mapa de OI');
							mapOrderItem.put(
								porder.OrderId,
								new List<OrderItem>{ porder }
							);
							//mapOrderTank.put(porder.OrderId, new List<Id>{porder.ESESO_fld_nombreTanqueL__c});
						}

3.1. First run

	@TestVisible
	private static Map<String, Map<String, Map<String, QueryExecuted>>> executeQueryObjetosLabel(
		Map<String, Map<String, Map<String, PicklistToExecute>>> mapParams,
		List<QueryExecuted> listQueryExec /*,SObject valoresObjeto*/
	) {

3.2. Second run

	@TestVisible
	private static Map<String, Map<String, Map<String, QueryExecuted>>> executeQueryObjetosLabel(
		Map<String, Map<String, Map<String, PicklistToExecute>>> mapParams,
		List<QueryExecuted> listQueryExec
	) {
		/*,SObject valoresObjeto*/

4.1. First run

	public static REP_obj_organizacionVenta__c createOrganizacionVtas(
		boolean bolInsert,
		String strCOdigoOrganizacion /*, REP_obj_sociedad__c objSociedad*/
	) {

4.2. Second run

	public static REP_obj_organizacionVenta__c createOrganizacionVtas(
		boolean bolInsert,
		String strCOdigoOrganizacion
	) {
		/*, REP_obj_sociedad__c objSociedad*/

Additional information (please fill this out):

  • OS: macos
  • Version (you can check this by running npm ls prettier-plugin-apex): [e.g. prettier-plugin-apex@2.0.0]
AP_SALESFORCE@ /Users/miguelnunezdiaz-montes/work/AP_SALESFORCE
└── prettier-plugin-apex@2.1.1
  • Prettier Version (you can check this by running npm ls prettier): [e.g. prettier@3.0.0]
AP_SALESFORCE@ /Users/miguelnunezdiaz-montes/work/AP_SALESFORCE
├─┬ prettier-plugin-apex@2.1.1
│ └── prettier@3.0.3 deduped
└── prettier@3.0.3
  • Java Version (you can check this by running java -version): [e.g. openjdk version "11"]
$ java -version
openjdk version "21.0.2" 2024-01-16 LTS
OpenJDK Runtime Environment Temurin-21.0.2+13 (build 21.0.2+13-LTS)
OpenJDK 64-Bit Server VM Temurin-21.0.2+13 (build 21.0.2+13-LTS, mixed mode)

Huge congrats again on the performance boost!!!!!!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions