Showing 9 of 46 total issues
Function Villages
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
exports.Villages = (province, district, sector, cell) => {
if (
province &&
district &&
sector &&
- 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 Cells
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
exports.Cells = (province, district, sector) => {
if (
province &&
district &&
sector &&
- 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 Sectors
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
exports.Sectors = (province, district) => {
if (province && district && datafile[formatInput(province)]) {
const sectors = datafile[formatInput(province)][formatInput(district)];
if (!sectors) {
throw Error("Given data was invalid");
- 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 Villages
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.Villages = (province, district, sector, cell) => {
if (
province &&
district &&
sector &&
Function Districts
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
exports.Districts = (provinces) => {
if (Array.isArray(provinces)) {
const districts = [];
for (const province of provinces) {
if (datafile[formatInput(province)]) {
- 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
Consider simplifying this complex logical expression. Open
if (
province &&
district &&
sector &&
cell &&
Function Cells
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.Cells = (province, district, sector) => {
if (
province &&
district &&
sector &&
Avoid deeply nested control flow statements. Open
for (const cell of Object.keys(
datafile[datafileProvince][datafileDistrict][datafileSector]
)) {
cells.push(cell);
}
Avoid deeply nested control flow statements. Open
for (const datafileCell of Object.keys(
datafile[datafileProvince][datafileDistrict][datafileSector]
)) {
for (const village of Object.keys(
datafile[datafileProvince][datafileDistrict][datafileSector][datafileCell]