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

Duplicated code and Failure to expand tonnes in mass.ts #594

Closed
burgerG opened this issue May 23, 2023 · 1 comment
Closed

Duplicated code and Failure to expand tonnes in mass.ts #594

burgerG opened this issue May 23, 2023 · 1 comment
Assignees
Labels
bug Something isn't working released

Comments

@burgerG
Copy link

burgerG commented May 23, 2023

Issue: Duplicated code and Failure to expand tonnes in mass.ts

Description:
There is a duplication of code in the mass.ts file, specifically in the conversions array. The expandMacro method is called twice with the same parameters, resulting in the duplication of conversions and a potential oversight. Additionally, this duplication prevents the proper expansion of units for ton (tonne) measurements.

Steps to Reproduce:

  1. Go to the mass.ts file.
  2. Locate the conversions array.
  3. Notice that the expandMacro method is called twice with the same parameters.

Expected Behavior:
The expandMacro method should be called only once with the appropriate parameters to avoid duplicated conversions. Furthermore, the expansion of units for ton (tonne) measurements should be included.

Actual Behavior:
The expandMacro method is called twice with the same parameters, leading to duplicate conversions. As a result, the expansion of units for ton (tonne) measurements is not present in the conversions.

Code Snippet:

const poundInGrams = new BigNumber(4.535_923_7e2);

export const mass: ReadonlyDeep<Family> = {
	// ...
	conversions: [
		{names: ['gram', 'grams'], symbols: ['g'], ratio: 1},
		...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),

		{names: ['tonne', 'tonnes', 'metric ton', 'metric tons'], symbols: ['t'], ratio: 1e6},
		...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),

		// ... other conversions ...
	],
};

Proposed Solution:
Remove the duplicated expandMacro method call at line 20, as it duplicates the conversions already added at line 17. Additionally, modify the second expandMacro call to properly expand the units for ton (tonne) measurements.

Replace method call at line 20

...expandMacro(Macros.si, {names: ['gram', 'grams'], symbols: ['g'], ratio: 1}),

with

...expandMacro(Macros.si, {names: ['tonne', 'tonnes', 'metric ton', 'metric tons'], symbols: ['t'], ratio: 1e6}),
@jonahsnider jonahsnider self-assigned this May 26, 2023
@jonahsnider jonahsnider added the bug Something isn't working label May 26, 2023
@jonahsnider
Copy link
Owner

🎉 This issue has been resolved in version 4.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants