modules/eventModule.js
Function hunt
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
static hunt(){
if(currentPreyScoutStatus)
{simulationLogs.push(new simulationLog(currentDate,"Hunt", "Wolf pack is on the prowl according to their scout activity findings."));
if(currentPreyCount>=1){
simulationLogs.push(new simulationLog(currentDate,"Hunt", "Wolf pack has found the prey/prey group. Engaging now."));
- 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 hunt
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static hunt(){
if(currentPreyScoutStatus)
{simulationLogs.push(new simulationLog(currentDate,"Hunt", "Wolf pack is on the prowl according to their scout activity findings."));
if(currentPreyCount>=1){
simulationLogs.push(new simulationLog(currentDate,"Hunt", "Wolf pack has found the prey/prey group. Engaging now."));
Avoid deeply nested control flow statements. Open
Open
if(environment.preyType===keys[i]){
return values[i];
}
Function scouting
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
static scouting(){
let roll=chance.integer({min:0,max:100});//0 and 100 included in range
//%25 chance to encounter wildcard wolves.
//%75 chance to track and find preys
//%20 chance to encounter predators
- 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"