Showing 4 of 4 total issues
Method VLOOKUP
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
public static string VLOOKUP(string lookupValue, DataTable dataTable, int index, int sortDirection)
{
ArgumentNullException.ThrowIfNull(dataTable);
foreach (DataColumn col in dataTable.Columns)
- 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 VLOOKUP
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static string VLOOKUP(string lookupValue, DataTable dataTable, int index, int sortDirection)
{
ArgumentNullException.ThrowIfNull(dataTable);
foreach (DataColumn col in dataTable.Columns)
Avoid deeply nested control flow statements. Open
if (value == lookupValue)
{
var offsetIndex = index - 1; // because excel stats at 1, not zero
var desiredColumnName = dataTable.Columns[offsetIndex].ColumnName;
var desiredValue = row[desiredColumnName].ToString();
Line length Open
SheetFunctions module for EngineBay published to [EngineBay.SheetFunctions](https://www.nuget.org/packages/EngineBay.SheetFunctions/) on NuGet.
- Read upRead up
- Exclude checks
MD013 - Line length
Tags: line_length
Aliases: line-length Parameters: linelength, codeblocks, tables (number; default 80, boolean; default true)
This rule is triggered when there are lines that are longer than the configured line length (default: 80 characters). To fix this, split the line up into multiple lines.
This rule has an exception where there is no whitespace beyond the configured line length. This allows you to still include items such as long URLs without being forced to break them in the middle.
You also have the option to exclude this rule for code blocks and tables. To
do this, set the code_blocks
and/or tables
parameters to false.
Code blocks are included in this rule by default since it is often a requirement for document readability, and tentatively compatible with code rules. Still, some languages do not lend themselves to short lines.