Showing 80 of 272 total issues
Function removeInvalidParentheses
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
var removeInvalidParentheses = function(rawString) {
const validExpression = new Set()
let leftToRemoveCount = 0
let rightToRemoveCount = 0
- 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
Function threeSum
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
const threeSum = nums => {
const result = []
nums.sort((a, b) => a > b)
for (let i = 0; i < nums.length; i++) {
let lowIndex = i + 1
- 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
Function isNumber
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
var isNumber = function(s) {
const trimmed = s.trim()
let flag = 0
let state = 0
- 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
Function accountsMerge
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
const accountsMerge = accounts => {
const ans = []
const emailGraph = {}
const emailToName = {}
- 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
Function isBipartite
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
var isBipartite = function (graph) {
const n = graph.length
const colors = Array(n).fill(-1) // -1 as uncoloerd
for (let start = 0; start < n; start++) {
- 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
Function removeInvalidParentheses
has 75 lines of code (exceeds 25 allowed). Consider refactoring. Open
var removeInvalidParentheses = function(rawString) {
const validExpression = new Set()
let leftToRemoveCount = 0
let rightToRemoveCount = 0
Function minWindow
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
var minWindow = function(s, t) {
if (s.length === 0 || t.length === 0) {
return ""
}
const dictT = new Map()
- 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
Function wordBreak
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
var wordBreak = function(s, wordDict) {
let map = new Map()
const dfs = (string, wordDict, start) => {
if (map.has(start)) return map.get(start) // use cache
- 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
Function alienOrder
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
const alienOrder = words => {
const graph = new Map()
for (const word of words) {
for (const char of word.split('')) {
- 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
Function addOperators
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
var addOperators = function (num, target) {
const ans = []
const helper = (index, path, value, prev) => {
if (index === num.length && value === target) {
// console.log('ret', ans, path)
- 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
Function recursive
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
const recursive = (string, index, leftCount, rightCount, leftRem, rightRem, expression) => {
// console.log(validExpression)
// console.log(index, leftCount, rightCount, leftRem, rightRem, expression)
if (index === string.length) {
// Base case: if index reaches the end of the string
Function searchRange
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
var searchRange = function(nums, target) {
let i = 0
let j = -1
while (i < nums.length) {
- 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
Function maxSumOfThreeSubarrays
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
var maxSumOfThreeSubarrays = function(nums, K) {
// W is an array of sums of windows
const W = Array(nums.length - K + 1).fill(0)
let sum = 0;
for (let i = 0; i < nums.length; i++) {
- 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
Function wordBreak2
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const wordBreak2 = (s, wordDict) => {
const dictSet = new Set(wordDict)
const queue = []
const visited = Array.from(Array(s.length)).map(() => 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
Function minDominoRotations
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
var minDominoRotations = function (A, B) {
const positionMap = new Map()
const A_ROW = 'A_ROW'
const B_ROW = 'B_ROW'
const BOTH = 'BOTH'
Function alienOrder
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const alienOrder = words => {
const graph = new Map()
for (const word of words) {
for (const char of word.split('')) {
Function longestPalindromeDP
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
const longestPalindromeDP = str => {
const dp = new Map()
if (!str) return ''
let longestStart = 0
let longestLength = 1
- 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
Function search
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
WordDictionary.prototype.search = function (word) {
const match = (words, k, node) => {
if (k === words.length) {
return node.word !== ""
}
- 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
Function minWindow
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
var minWindow = function(s, t) {
if (s.length === 0 || t.length === 0) {
return ""
}
const dictT = new Map()
Function maxSumOfThreeSubarrays
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
var maxSumOfThreeSubarrays = function(nums, K) {
// W is an array of sums of windows
const W = Array(nums.length - K + 1).fill(0)
let sum = 0;
for (let i = 0; i < nums.length; i++) {