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

remove redundant parens #1363

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Humanizer.Tests.Shared/BitFieldEnumHumanizeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void CanHumanizeMultipleWordDescriptionAttribute() =>
[Fact]
public void CanHumanizeMultipleValueBitFieldEnum()
{
var xoredBitFlag = (BitFieldEnumUnderTest.RED | BitFieldEnumUnderTest.DARK_GRAY);
var xoredBitFlag = BitFieldEnumUnderTest.RED | BitFieldEnumUnderTest.DARK_GRAY;
Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize());
}

Expand All @@ -29,7 +29,7 @@ public void CanHumanizeShortMultipleWordDescriptionAttribute() =>
[Fact]
public void CanHumanizeShortMultipleValueBitFieldEnum()
{
var xoredBitFlag = (ShortBitFieldEnumUnderTest.RED | ShortBitFieldEnumUnderTest.DARK_GRAY);
var xoredBitFlag = ShortBitFieldEnumUnderTest.RED | ShortBitFieldEnumUnderTest.DARK_GRAY;
Assert.Equal(BitFlagEnumTestsResources.ExpectedResultWhenBothValuesXored, xoredBitFlag.Humanize());
}

Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer.Tests.Shared/MetricNumeralTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void TestAllSymbolsAsInt(int exponent)
[Theory]
[InlineData("0", 0d, false, true, null)]
[InlineData("123", 123d, false, true, null)]
[InlineData("-123", (-123d), false, true, null)]
[InlineData("-123", -123d, false, true, null)]
[InlineData("1.23k", 1230d, false, true, null)]
[InlineData("1 k", 1000d, true, true, null)]
[InlineData("1 kilo", 1000d, true, false, null)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private static string PrecisionHumanize(TimeSpan ts, Tense tense, double precisi
{
var factor = Convert.ToInt32(Math.Floor((double)days / 30));
var maxMonths = Convert.ToInt32(Math.Ceiling((double)days / 30));
months = (days >= 30 * (factor + precision)) ? maxMonths : maxMonths - 1;
months = days >= 30 * (factor + precision) ? maxMonths : maxMonths - 1;
}

// year calculation
Expand All @@ -89,7 +89,7 @@ private static string PrecisionHumanize(TimeSpan ts, Tense tense, double precisi
{
var factor = Convert.ToInt32(Math.Floor((double)days / 365));
var maxMonths = Convert.ToInt32(Math.Ceiling((double)days / 365));
years = (days >= 365 * (factor + precision)) ? maxMonths : maxMonths - 1;
years = days >= 365 * (factor + precision) ? maxMonths : maxMonths - 1;
}

// start computing result from larger units to smaller ones
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/FluentDate/In.SomeTimeFrom.tt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Humanizer;
public partial class In
{
<#for (var i = 1; i <= 10; i++){
var plural = ( i > 1 ? "s" : "");
var plural = i > 1 ? "s" : "";
var second = "Second" + plural;
var minute = "Minute" + plural;
var hour = "Hour" + plural;
Expand Down
2 changes: 1 addition & 1 deletion src/Humanizer/FluentDate/InDate.SomeTimeFrom.tt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Humanizer;
public partial class InDate
{
<#for (var i = 1; i <= 10; i++){
var plural = ( i > 1 ? "s" : "");
var plural = i > 1 ? "s" : "";

var day = "Day" + plural;
var week = "Week" + plural;
Expand Down
6 changes: 3 additions & 3 deletions src/Humanizer/HeadingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static class HeadingExtensions
/// <param name="culture">The culture to return the textual representation in</param>
public static string ToHeading(this double heading, HeadingStyle style = HeadingStyle.Abbreviated, CultureInfo culture = null)
{
var val = (int)((heading / 22.5) + .5);
var val = (int)(heading / 22.5 + .5);

var result = Headings[val % 16];

Expand All @@ -58,7 +58,7 @@ public static string ToHeading(this double heading, HeadingStyle style = Heading
/// <returns>The heading arrow.</returns>
public static char ToHeadingArrow(this double heading)
{
var val = (int)((heading / 45) + .5);
var val = (int)(heading / 45 + .5);

return HeadingArrows[val % 8];
}
Expand Down Expand Up @@ -111,7 +111,7 @@ public static double FromHeadingArrow(this char heading)
return -1;
}

return (index * 45.0);
return index * 45.0;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,25 @@ private string Convert(int number, bool isOrdinal)

var parts = new List<string>();

if ((number / 1000000000) > 0)
if (number / 1000000000 > 0)
{
parts.Add($"{Convert(number / 1000000000)} miljard");
number %= 1000000000;
}

if ((number / 1000000) > 0)
if (number / 1000000 > 0)
{
parts.Add($"{Convert(number / 1000000)} miljoen");
number %= 1000000;
}

if ((number / 1000) > 0)
if (number / 1000 > 0)
{
parts.Add($"{Convert(number / 1000)} duisend");
number %= 1000;
}

if ((number / 100) > 0)
if (number / 100 > 0)
{
parts.Add($"{Convert(number / 100)} honderd");
number %= 100;
Expand All @@ -85,13 +85,13 @@ private string Convert(int number, bool isOrdinal)
}
else
{
var lastPartValue = (number / 10) * 10;
var lastPartValue = number / 10 * 10;
var lastPart = TensMap[number / 10];
if ((number % 10) > 0)
if (number % 10 > 0)
{
lastPart = $"{GetUnitValue(number % 10, false)} en {(isOrdinal ? GetUnitValue(lastPartValue, isOrdinal) : lastPart)}";
}
else if ((number % 10) == 0)
else if (number % 10 == 0)
{
lastPart = $"{(parts.Count > 0 ? "en " : "")}{lastPart}{(isOrdinal ? "ste" : "")}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public override string Convert(long number, GrammaticalGender gender, bool addAn
else
{
var ones = tens % 10;
tens = (tens / 10);
tens = tens / 10;

if (ones > 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,40 @@ private string ConvertImpl(long number, bool isOrdinal)

var parts = new List<string>();

if ((number / 1000000000000000000) > 0)
if (number / 1000000000000000000 > 0)
{
parts.Add($"{Convert(number / 1000000000000000000)} քվինտիլիոն");
number %= 1000000000000000000;
}

if ((number / 1000000000000000) > 0)
if (number / 1000000000000000 > 0)
{
parts.Add($"{Convert(number / 1000000000000000)} կվադրիլիոն");
number %= 1000000000000000;
}

if ((number / 1000000000000) > 0)
if (number / 1000000000000 > 0)

{
parts.Add($"{Convert(number / 1000000000000)} տրիլիոն");
number %= 1000000000000;
}

if ((number / 1000000000) > 0)
if (number / 1000000000 > 0)
{
parts.Add($"{Convert(number / 1000000000)} միլիարդ");
number %= 1000000000;
}

if ((number / 1000000) > 0)
if (number / 1000000 > 0)
{
parts.Add($"{Convert(number / 1000000)} միլիոն");
number %= 1000000;
}

if ((number / 1000) > 0)
if (number / 1000 > 0)
{
if ((number / 1000) == 1)
if (number / 1000 == 1)
{
parts.Add("հազար");
}
Expand All @@ -97,9 +97,9 @@ private string ConvertImpl(long number, bool isOrdinal)
number %= 1000;
}

if ((number / 100) > 0)
if (number / 100 > 0)
{
if ((number / 100) == 1)
if (number / 100 == 1)
{
parts.Add("հարյուր");
}
Expand All @@ -120,7 +120,7 @@ private string ConvertImpl(long number, bool isOrdinal)
else
{
var lastPart = TensMap[number / 10];
if ((number % 10) > 0)
if (number % 10 > 0)
{
lastPart += $"{GetUnitValue(number % 10, isOrdinal)}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,33 @@ public override string Convert(long input)

var parts = new List<string>();

if ((number / 1000000000) > 0)
if (number / 1000000000 > 0)
{
parts.Add($"{Convert(number / 1000000000)} milyard");
number %= 1000000000;
}

if ((number / 1000000) > 0)
if (number / 1000000 > 0)
{
parts.Add($"{Convert(number / 1000000)} milyon");
number %= 1000000;
}

var thousand = (number / 1000);
var thousand = number / 1000;
if (thousand > 0)
{
parts.Add($"{(thousand > 1 ? Convert(thousand) : "")} min".Trim());
number %= 1000;
}

var hundred = (number / 100);
var hundred = number / 100;
if (hundred > 0)
{
parts.Add($"{(hundred > 1 ? Convert(hundred) : "")} yüz".Trim());
number %= 100;
}

if ((number / 10) > 0)
if (number / 10 > 0)
{
parts.Add(TensMap[number / 10]);
number %= 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ public override string Convert(long input)

var parts = new List<string>();

if ((number / 10000000) > 0)
if (number / 10000000 > 0)
{
parts.Add($"{Convert(number / 10000000)} কোটি");
number %= 10000000;
}

if ((number / 100000) > 0)
if (number / 100000 > 0)
{
parts.Add($"{Convert(number / 100000)} লক্ষ");
number %= 100000;
}

if ((number / 1000) > 0)
if (number / 1000 > 0)
{
parts.Add($"{Convert(number / 1000)} হাজার");
number %= 1000;
}

if ((number / 100) > 0)
if (number / 100 > 0)
{
parts.Add($"{HundredsMap[number / 100]}");
number %= 100;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd

var parts = new List<string>();

if ((number / 1000000000) > 0)
if (number / 1000000000 > 0)
{
// gender is not applied for billions
parts.Add(number / 1000000000 >= 2
Expand All @@ -41,7 +41,7 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd
number %= 1000000000;
}

if ((number / 1000000) > 0)
if (number / 1000000 > 0)
{
// gender is not applied for millions
parts.Add(number / 1000000 >= 2
Expand All @@ -51,14 +51,14 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd
number %= 1000000;
}

if ((number / 1000) > 0)
if (number / 1000 > 0)
{
// gender is not applied for thousands
parts.Add(number / 1000 == 1 ? "mil" : $"{Convert(number / 1000, GrammaticalGender.Masculine)} mil");
number %= 1000;
}

if ((number / 100) > 0)
if (number / 100 > 0)
{
if (number == 100)
{
Expand All @@ -67,7 +67,7 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd
else
{
// Gender is applied to hundreds starting from 200
parts.Add(ApplyGender(PortugueseHundredsMap[(number / 100)], gender));
parts.Add(ApplyGender(PortugueseHundredsMap[number / 100], gender));
}

number %= 100;
Expand All @@ -87,7 +87,7 @@ public override string Convert(long input, GrammaticalGender gender, bool addAnd
else
{
var lastPart = PortugueseTensMap[number / 10];
if ((number % 10) > 0)
if (number % 10 > 0)
{
lastPart += $" e {ApplyGender(PortugueseUnitsMap[number % 10], gender)}";
}
Expand All @@ -109,7 +109,7 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender)

var parts = new List<string>();

if ((number / 1000000000) > 0)
if (number / 1000000000 > 0)
{
parts.Add(number / 1000000000 == 1
? ApplyOrdinalGender("bilionésimo", gender)
Expand All @@ -118,7 +118,7 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender)
number %= 1000000000;
}

if ((number / 1000000) > 0)
if (number / 1000000 > 0)
{
parts.Add(number / 1000000 == 1
? ApplyOrdinalGender("milionésimo", gender)
Expand All @@ -127,7 +127,7 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender)
number %= 1000000;
}

if ((number / 1000) > 0)
if (number / 1000 > 0)
{
parts.Add(number / 1000 == 1
? ApplyOrdinalGender("milésimo", gender)
Expand All @@ -136,13 +136,13 @@ public override string ConvertToOrdinal(int number, GrammaticalGender gender)
number %= 1000;
}

if ((number / 100) > 0)
if (number / 100 > 0)
{
parts.Add(ApplyOrdinalGender(PortugueseOrdinalHundredsMap[number / 100], gender));
number %= 100;
}

if ((number / 10) > 0)
if (number / 10 > 0)
{
parts.Add(ApplyOrdinalGender(PortugueseOrdinalTensMap[number / 10], gender));
number %= 10;
Expand Down
Loading