Showing 30 of 115 total issues
File template.ts
has 818 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Achievement, Biome, BiomeType, Building, Citizen, Civilization,
Collection, Economy, Era, FaithBonus, FaithTier, Game, Leader, Legacy,
log, Nation, notify, Queue, Resource, Robot, Settings, SocialPolicy,
Soldier, Tech, generateTooltips, updateTooltip, betterUpdateTooltip,
Trait, Wonder
File tech.ts
has 391 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Utils } from '../utils';
import { Tech, Collection, Resource, Building, Wonder, Civilization, Citizen } from '../classes';
let u = new Utils();
Function createResourcesScreen
has 112 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createResourcesScreen(playerCiv:Civilization, resources:Collection<Resource>) {
let resourcesScreen = `
<section class='screen resources-screen' id='resources'>
<h2 data-tooltip='Resources are nice.'><img src='img/resources.png'> Resources</h2>
<section class='resources-screen-inner'>
Function createCivilizationScreen
has 105 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createCivilizationScreen(playerCiv:Civilization):string {
let civilizationScreen = `
<section class='screen civilization-screen' id='civilization'>
<h2><img src='img/empire.png'> Civilization</h2>
<section class='civilization-screen-inner'>
Function notify
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
Open
export function notify(note:Note, isWindowActive:boolean = true):void {
if (prevNoteMessage !== note.message) {
if (isWindowActive) {
if (typeof note.time === 'undefined') {
note.time = 2500;
- 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 cultureCardEvents
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function cultureCardEvents(socialPolicies:Collection<SocialPolicy>, playerCiv) {
let cc = u.elt('.culture-card', true);
iterateOverNodelist(cc, (item, index) => {
let cardName = item.getAttribute('data-name');
let card = socialPolicies.get(cardName);
Function constructor
has 80 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
constructor(civName:string, leaderName:string, leader:Leader, biomes:Collection<Biome>) {
this.civName = civName;
this.leaderName = leaderName;
//this.location = location;
this.biomes = biomes;
Templates
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class Templates {
createStartScreen(playerCiv:Civilization, game:Game) {
let startScreen = `
Function createDiplomacyScreen
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createDiplomacyScreen(playerCiv:Civilization) {
let diplomacyScreen = `
<section class='screen diplomacy-screen' id='diplomacy'>
<h2>
<img src='img/deal.png'> Diplomacy
Function notify
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function notify(note:Note, isWindowActive:boolean = true):void {
if (prevNoteMessage !== note.message) {
if (isWindowActive) {
if (typeof note.time === 'undefined') {
note.time = 2500;
Function createCultureScreen
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createCultureScreen(playerCiv:Civilization) {
let cultureScreen = `
<section class='screen culture-screen' id='culture'>
<div class='expand culture-expand' title='Expand the screen size.'>
<img src='img/expand.png'>
Function updatePopulation
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function updatePopulation(pop:number, playerCiv:Civilization, game:Game, citizens:Collection<Citizen>, options) {
let popGrowthCost = u.elt('.pop-growth-cost-text');
let populationText = u.elt('.population-text');
let popMetric = u.elt('.metric-population');
Function biomeSelection
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function biomeSelection(biomeInput) {
bindElement('.biome-select-dropdown', 'click', () => { toggleBiomeSelectDropdown() });
Function createSettingsScreen
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createSettingsScreen(playerCiv:Civilization, game:Game) {
let settingsScreen = `
<section class='screen settings-screen' id='settings'>
<h2>
<img src='img/gear.png'> Settings
Function createEconomyScreen
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createEconomyScreen(playerCiv:Civilization) {
let economyScreen = `
<section class='screen economy-screen' id='economy'>
<h2><img src='img/money.png'> Economy</h2>
<section class='economy-screen-inner'>
Function faithBonusClick
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function faithBonusClick(playerCiv:Civilization) {
//playerCiv.faithPM += 30;
//updateFaithElts();
let fbs = document.querySelectorAll('.faith-bonus');
[].forEach.call(fbs, function (item:any) {
Function createScreenHeader
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createScreenHeader(playerCiv:Civilization, game:Game):string {
let screenHeader = `
<header class='screen-header'>
<div class='player-info'>
<img src='img/${u.dasherize(playerCiv.leader.name)}.jpg'>
Function calculateTotalMilitaryStats
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function calculateTotalMilitaryStats(military:Collection<Soldier>, soldier:Citizen, playerCiv:Civilization) {
console.log(soldier);
let statsContainer = u.elt('.assignment-total');
let totalAssigned = u.elt('.soldiers-assigned');
Function militaryUnitChange
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function militaryUnitChange(military:Collection<Soldier>, soldier:Citizen, playerCiv:Civilization) {
iterateOverNodelist(u.elt('.military-assignment-input', true), (item:HTMLInputElement, index) => {
item.addEventListener('change', (event:Event) => {
let unitName = item.getAttribute('data-unit');
let unit:Soldier = military.get(unitName);
Function createTechnologyScreen
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createTechnologyScreen(playerCiv:Civilization) {
let technologyScreen = `
<section class='screen technology-screen' id='technology'>
<h2><img src='img/research.png'> Technology</h2>
<section class='technology-screen-inner'>