EmmaRamirez/Clickopolis

View on GitHub

Showing 115 of 115 total issues

Identical blocks of code found in 2 locations. Consider refactoring.
Open

export function generateTooltips(opts:TooltipOptions = {
  offsetX: 10,
  offsetY: 10
 }) {
  let tooltipElts = u.elt('[data-tooltip]', true);
Severity: Major
Found in src/classes/tooltip.ts and 1 other location - About 2 days to fix
src/classes/tooltips.ts on lines 14..40

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 407.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Identical blocks of code found in 2 locations. Consider refactoring.
Open

export function generateTooltips(opts:TooltipOptions = {
  offsetX: 10,
  offsetY: 10
 }) {
  let tooltipElts = u.elt('[data-tooltip]', true);
Severity: Major
Found in src/classes/tooltips.ts and 1 other location - About 2 days to fix
src/classes/tooltip.ts on lines 14..40

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 407.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

File template.ts has 818 lines of code (exceeds 250 allowed). Consider refactoring.
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
Severity: Major
Found in src/components/template.ts - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    export function updateTooltip(elt: HTMLElement, opts:TooltipOptions = {
      offsetX: 10,
      offsetY: 10
    }) {
      let text = elt.getAttribute('data-tooltip');
    Severity: Major
    Found in src/classes/tooltip.ts and 1 other location - About 1 day to fix
    src/classes/tooltips.ts on lines 47..76

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 329.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    export function updateTooltip(elt: HTMLElement, opts:TooltipOptions = {
      offsetX: 10,
      offsetY: 10
    }) {
      let text = elt.getAttribute('data-tooltip');
    Severity: Major
    Found in src/classes/tooltips.ts and 1 other location - About 1 day to fix
    src/classes/tooltip.ts on lines 47..76

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 329.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function woodcutterFunction (resources, amount, woodcutter) {
        resources.get('prod').perClick += amount * woodcutter.contrib1.amount;
      resources.get('prod').perSecond += amount * woodcutter.contrib2.amount;
      u.elt('.r-prod-pc').textContent = resources.get('prod').perClick.toFixed(1);
      u.elt('.r-prod-ps').textContent = resources.get('prod').perSecond.toFixed(1);
    Severity: Major
    Found in src/data/citizen-function.ts and 1 other location - About 6 hrs to fix
    src/data/citizen-function.ts on lines 22..28

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 170.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    function minerFunction (resources, amount, miner) {
        resources.get('prod').perClick += amount * miner.contrib1.amount;
      resources.get('prod').perSecond += amount * miner.contrib2.amount;
      u.elt('.r-prod-pc').textContent = resources.get('prod').perClick.toFixed(1);
      u.elt('.r-prod-ps').textContent = resources.get('prod').perSecond.toFixed(1);
    Severity: Major
    Found in src/data/citizen-function.ts and 1 other location - About 6 hrs to fix
    src/data/citizen-function.ts on lines 30..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 170.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    File tech.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Utils } from '../utils';
    import { Tech, Collection, Resource, Building, Wonder, Civilization, Citizen } from '../classes';
    
    let u = new Utils();
    
    
    Severity: Minor
    Found in src/data/tech.ts - About 5 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        constructor(name:string, image:number, color:string, description:string, influence:number, strength:number, defense:number, cash:number, peacefulness:number, isAtWar:boolean, timesInteracted:number = 0) {
          this.name = name;
          this.image = image;
          this.color = color;
          this.description = description;
      Severity: Major
      Found in src/classes/nation.ts and 1 other location - About 4 hrs to fix
      src/classes/citizen.ts on lines 26..38

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 125.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        constructor(name:string, image:string, color:string, amount: number, description: string, contrib1: Contribution, contrib2: Contribution, contrib3: Contribution, contrib4: Contribution, visible: boolean = true, enabled: boolean = false) {
          this.name = name;
          this.image = image;
          this.color = color;
          this.amount = amount;
      Severity: Major
      Found in src/classes/citizen.ts and 1 other location - About 4 hrs to fix
      src/classes/nation.ts on lines 14..26

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 125.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Function createResourcesScreen has 112 lines of code (exceeds 25 allowed). Consider refactoring.
      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'>
      Severity: Major
      Found in src/components/template.ts - About 4 hrs to fix

        Function createCivilizationScreen has 105 lines of code (exceeds 25 allowed). Consider refactoring.
        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'>
        Severity: Major
        Found in src/components/template.ts - About 4 hrs to fix

          Function notify has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
          Open

          export function notify(note:Note, isWindowActive:boolean = true):void {
            if (prevNoteMessage !== note.message) {
              if (isWindowActive) {
                if (typeof note.time === 'undefined') {
                  note.time = 2500;
          Severity: Minor
          Found in src/classes/notify.ts - About 4 hrs to fix

          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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            constructor(name:string, perClick:number, perSecond:number, max:number, total:number, image:string, description: string, unlocked: boolean, visible: boolean = true) {
              this.name = name;
              this.perClick = perClick;
              this.perSecond = perSecond;
              this.max = max;
          Severity: Major
          Found in src/classes/resource.ts and 1 other location - About 3 hrs to fix
          src/classes/building.ts on lines 12..22

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 103.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            constructor(name:string, amount:number, prodCost:number, cashCost:number, description:string, effect:string, visible: boolean, enabled: boolean, func:Function = null) {
              this.name = name;
              this.amount = amount;
              this.prodCost = prodCost;
              this.cashCost = cashCost;
          Severity: Major
          Found in src/classes/building.ts and 1 other location - About 3 hrs to fix
          src/classes/resource.ts on lines 25..35

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 103.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          let granary:Building = new Building('Granary', 0, 25, 250, 'Feeds all your cute animals.', '+200 <img src="img/food.png"> max', true, false, function (args) {
            args.resources.get('food').max += 200;
            //notify({message: `Your civilization now has a max <img src="img/food.png"> storage of ${resources.get('food').max}`});
            u.elt('.r-food-max').textContent = u.abbrNum(args.resources.get('food').max);
          });
          Severity: Major
          Found in src/data/building.ts and 1 other location - About 3 hrs to fix
          src/data/building.ts on lines 21..25

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 101.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          let quarry:Building = new Building('Quarry', 0, 30, 300, 'Your very own diamond in the rough.', '+200 <img src="img/prod.png"> max', true, false, function (args) {
            args.resources.get('prod').max += 200;
            //notify({message: `Your civilization now has a max <img src="img/prod.png"> capacity of ${resources.get('food').max}`});
            u.elt('.r-prod-max').textContent = u.abbrNum(args.resources.get('prod').max);
          });
          Severity: Major
          Found in src/data/building.ts and 1 other location - About 3 hrs to fix
          src/data/building.ts on lines 16..20

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 101.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Function cultureCardEvents has 81 lines of code (exceeds 25 allowed). Consider refactoring.
          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);
          Severity: Major
          Found in src/utils/culture.ts - About 3 hrs to fix

            Function constructor has 80 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              constructor(civName:string, leaderName:string, leader:Leader, biomes:Collection<Biome>) {
                this.civName = civName;
                this.leaderName = leaderName;
                //this.location = location;
                this.biomes = biomes;
            Severity: Major
            Found in src/classes/civilization.ts - About 3 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                function (citizens:Collection<Citizen>, resources:Collection<Resource>, playerCiv:Civilization, buildings:Collection<Building>, wonders:Collection<Wonder>) {
                  u.unlockResource('banana', resources);
                  u.unlockWonder('Moai Statues', wonders);
                }
              Severity: Major
              Found in src/data/tech.ts and 1 other location - About 2 hrs to fix
              src/data/tech.ts on lines 263..266

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 89.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language