Showing 14 of 14 total issues
Method Replace
has a Cognitive Complexity of 62 (exceeds 20 allowed). Consider refactoring. Open
public string Replace(string text)
{
StringBuilder result = new StringBuilder(text.Length);
bool foundMatch = false;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method ReplaceWithSameCase
has a Cognitive Complexity of 56 (exceeds 20 allowed). Consider refactoring. Open
[Pure]
public static string ReplaceWithSameCase(this string str, string oldValue, string newValue, StringComparison strComp = StringComparison.CurrentCultureIgnoreCase)
{
// Check inputs.
if (str == null)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Process
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
[Pure]
public string Process(string text, bool givenName, bool noun = false, bool hyphenateSyllables = false)
{
text = text
// Replace common alternate characters
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method ToRomanNumerals
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
[Pure]
public static string ToRomanNumerals(this decimal num)
{
if (num < 0)
throw new ArgumentOutOfRangeException(nameof(num), num, "Must be a non-negative value");
Method Replace
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
public string Replace(string text)
{
StringBuilder result = new StringBuilder(text.Length);
bool foundMatch = false;
Method ReplaceWithSameCase
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
[Pure]
public static string ReplaceWithSameCase(this string str, string oldValue, string newValue, StringComparison strComp = StringComparison.CurrentCultureIgnoreCase)
{
// Check inputs.
if (str == null)
File ModifiedHepburn.cs
has 261 lines of code (exceeds 250 allowed). Consider refactoring. Open
using Romanization.Internal;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Globalization;
Method Process
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
[Pure]
public string Process(string text, bool givenName, bool noun = false, bool hyphenateSyllables = false)
{
text = text
// Replace common alternate characters
Method Process
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
[Pure]
internal NumeralValue Process(string text, bool? textUsesOverbars)
{
// Clean, normalize, and prepare the text
// TODO: This could be done much more efficiently, but this system should only ever be used for small strings so the impact shouldn't be very high
Method Generate
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public string Generate(CasingMode casingMode, IList<string> captures)
{
if (captures.Count != ExpectedCaptureCount)
throw new CaptureCountMismatchException(
$"Number of captures provided ({captures.Count}) does not match the expected number ({ExpectedCaptureCount}).",
Avoid deeply nested control flow statements. Open
if (match.Groups[i].Index + match.Groups[i].Length <= searchStart)
{
lastCharIndex = searchStart;
break;
}
Avoid deeply nested control flow statements. Open
if (!noun && jamoList[i + 1] == 'ㅎ' &&
(jamoList[i] == 'ㄱ' || jamoList[i] == 'ㄷ' || jamoList[i] == 'ㅂ'))
romanizedText.Append(hyphenateSyllables
? specialCaseRomanization.ToString(false)
: specialCaseRomanization.BaseString.NonAspiratedString);
Consider simplifying this complex logical expression. Open
if (firstCharIndex > -1)
{
searchStart = match.Index + match.Length - 1;
if (!_countCapturesInCasing)
for (int i = match.Groups.Count - 1; i >= 1; i--)
Consider simplifying this complex logical expression. Open
if (newValue.Length > 1)
{
bool lastCharUpper = char.IsUpper(str[foundAt + oldValue.Length - 1]) &&
(oldValue.Length > 1 ||
(str.Length > foundAt + 1 && char.IsUpper(str[foundAt + 1])) ||