Showing 323 of 498 total issues
Function isValidSudoku
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
var isValidSudoku = function(board) {
for (let i = 0; i < 9; i++) {
const hash = {};
for (let j = 0; j < 9; j++) {
const num = board[i][j];
- 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 fourSum
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
function fourSum(nums, target) {
if (nums.length < 4) return [];
nums.sort((x, y) => x - y);
const res = [];
- 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 splitIntoFibonacci
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
var splitIntoFibonacci = function(S) {
const res = [];
backtrack(res, 0);
function backtrack(res, startIndex) {
- 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 fourSum
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
export const fourSum = (nums, target) => {
nums.sort((x, y) => x - y);
let res = [];
for (let i = 0; i < nums.length - 3; 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 queensAttacktheKing
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
var queensAttacktheKing = function(queens, king) {
let res = [];
const queensMap = queens.map(arr => String(arr[0]) + String(arr[1]));
let column = king[0];
let row = king[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 numMagicSquaresInside
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
export function numMagicSquaresInside(grid) {
let res = 0;
for (let i = 0; i < grid.length - 2; i++) {
for (let j = 0; j < grid[0].length - 2; j++) {
let guard = true;
- 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 23 (exceeds 5 allowed). Consider refactoring. Open
function threeSum(nums) {
if (nums.length < 3) return [];
nums.sort((x, y) => x - y);
const res = [];
- 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 findMedianSortedArrays
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
var findMedianSortedArrays = function(nums1, nums2) {
while (nums1.length + nums2.length > 2) {
if (nums1.length === 0) {
nums2.pop();
nums2.shift();
- 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 queensAttacktheKing
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
var queensAttacktheKing = function(queens, king) {
let res = [];
const queensMap = queens.map(arr => String(arr[0]) + String(arr[1]));
let column = king[0];
let row = king[1];
Function updateMatrix
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
export const updateMatrix = matrix => {
let res = [];
for (let i = 0; i < matrix.length; i++) {
res.push([]);
}
- 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 findMedianSortedArrays
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
var findMedianSortedArrays = function (nums1, nums2) {
const len = nums1.length + nums2.length;
if (len === 1) {
return ~~nums1[0] + ~~nums2[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 countServers
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
var countServers = function (grid) {
const arrX = [];
const arrY = [];
let res = 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 invalidTransactions
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
var invalidTransactions = function (transactions) {
let res = [];
let map = {};
// 以名字区分
for (let t of transactions) {
- 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 peopleIndexes
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
var peopleIndexes = function (favoriteCompanies) {
let res = [];
let len = favoriteCompanies.length;
for (let i = 0; i < len; 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 threeSum
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
export const threeSum = (nums) => {
nums.sort((a, b) => a - b);
let res = [];
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 decodeAtIndex
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
var decodeAtIndex = function (S, K) {
let size = 0;
for (let i = 0; i < S.length; i++) {
// 计算size
- 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 a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
var minDominoRotations = function (A, B) {
let helper = function (num) {
let toTop = 0;
let toBottom = 0;
for (let i = 0, len = A.length; i < len; ++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 largestTimeFromDigits
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
var largestTimeFromDigits = function(A) {
let res = -1;
for (let i = 0; i < 4; i++) {
for (let j = 0; j < 4; j++) {
for (let k = 0; k < 4; k++) {
- 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 spiralOrder
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export const spiralOrder = matrix => {
let res = [];
const row = matrix.length;
if (!Array.isArray(matrix[0])) return matrix;
- 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 delNodes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
var delNodes = function (root, to_delete) {
var res = [];
var deleteSet = new Set(to_delete);
dfs(null, root);
if (!deleteSet.has(root.val)) res.push(root);
- 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"