Mirroar/hivemind

View on GitHub

Showing 1,348 of 1,349 total issues

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

    {
        label: '⛏',
        resources: [
            {color: '#285F7E', resourceType: RESOURCE_UTRIUM_BAR, hidden: true, scale: 2 / 5, label: 'U🪨'},
            {color: '#78D4F5', resourceType: RESOURCE_UTRIUM, hidden: true, scale: 2},
Severity: Major
Found in src/report/resources.ts and 3 other locations - About 3 hrs to fix
src/report/resources.ts on lines 34..43
src/report/resources.ts on lines 54..63
src/report/resources.ts on lines 94..103

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 102.

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 4 locations. Consider refactoring.
Open

    {
        label: '🧨',
        resources: [
            {color: '#5A4D32', resourceType: RESOURCE_ZYNTHIUM_BAR, height: 2, scale: 2 / 5, label: 'Z🪨'},
            {color: '#F6D592', resourceType: RESOURCE_ZYNTHIUM, height: 2, scale: 2},
Severity: Major
Found in src/report/resources.ts and 3 other locations - About 3 hrs to fix
src/report/resources.ts on lines 24..33
src/report/resources.ts on lines 44..53
src/report/resources.ts on lines 64..73

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 102.

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

            if (store[RESOURCE_ENERGY] < creep.store.getCapacity() * 2) {
                option.priority -= creep.room.getCreepsWithOrder('getEnergy', target.id).length * 3;
                option.priority -= creep.room.getCreepsWithOrder('getResource', target.id).length * 3;
            }
Severity: Major
Found in src/role/transporter.ts and 1 other location - About 3 hrs to fix
src/role/transporter.ts on lines 636..639

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 102.

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 4 locations. Consider refactoring.
Open

    {
        label: '📦',
        resources: [
            {color: '#32167E', resourceType: RESOURCE_KEANIUM_BAR, height: 2, scale: 2 / 5, label: 'K🪨'},
            {color: '#9973F7', resourceType: RESOURCE_KEANIUM, height: 2, scale: 2},
Severity: Major
Found in src/report/resources.ts and 3 other locations - About 3 hrs to fix
src/report/resources.ts on lines 44..53
src/report/resources.ts on lines 64..73
src/report/resources.ts on lines 84..93

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 102.

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

                if (store[resourceType] < creep.store.getCapacity() * 2) {
                    option.priority -= creep.room.getCreepsWithOrder('getEnergy', target.id).length * 2;
                    option.priority -= creep.room.getCreepsWithOrder('getResource', target.id).length * 2;
                }
Severity: Major
Found in src/role/transporter.ts and 1 other location - About 3 hrs to fix
src/role/transporter.ts on lines 571..574

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 102.

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 4 locations. Consider refactoring.
Open

    {
        label: '⚔️',
        resources: [
            {color: '#285F7E', resourceType: RESOURCE_UTRIUM_BAR, height: 2, scale: 2 / 5, label: 'U🪨'},
            {color: '#78D4F5', resourceType: RESOURCE_UTRIUM, height: 2, scale: 2},
Severity: Major
Found in src/report/resources.ts and 3 other locations - About 3 hrs to fix
src/report/resources.ts on lines 24..33
src/report/resources.ts on lines 44..53
src/report/resources.ts on lines 84..93

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 102.

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 4 locations. Consider refactoring.
Open

    {
        label: '🏹',
        resources: [
            {color: '#32167E', resourceType: RESOURCE_KEANIUM_BAR, hidden: true, scale: 2 / 5, label: 'K🪨'},
            {color: '#9973F7', resourceType: RESOURCE_KEANIUM, hidden: true, scale: 2},
Severity: Major
Found in src/report/resources.ts and 3 other locations - About 3 hrs to fix
src/report/resources.ts on lines 54..63
src/report/resources.ts on lines 74..83
src/report/resources.ts on lines 94..103

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 102.

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 4 locations. Consider refactoring.
Open

    {
        label: '💊',
        resources: [
            {color: '#346046', resourceType: RESOURCE_LEMERGIUM_BAR, hidden: true, scale: 2 / 5, label: 'L🪨'},
            {color: '#70F0A9', resourceType: RESOURCE_LEMERGIUM, hidden: true, scale: 2},
Severity: Major
Found in src/report/resources.ts and 3 other locations - About 3 hrs to fix
src/report/resources.ts on lines 34..43
src/report/resources.ts on lines 74..83
src/report/resources.ts on lines 94..103

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 102.

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 4 locations. Consider refactoring.
Open

    {
        label: '🚲',
        resources: [
            {color: '#5A4D32', resourceType: RESOURCE_ZYNTHIUM_BAR, hidden: true, scale: 2 / 5, label: 'Z🪨'},
            {color: '#F6D592', resourceType: RESOURCE_ZYNTHIUM, hidden: true, scale: 2},
Severity: Major
Found in src/report/resources.ts and 3 other locations - About 3 hrs to fix
src/report/resources.ts on lines 34..43
src/report/resources.ts on lines 54..63
src/report/resources.ts on lines 74..83

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 102.

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 brawler.ts has 306 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* global RoomPosition MOVE ATTACK HEAL RANGED_ATTACK ATTACK_POWER
RANGED_ATTACK_POWER HEAL_POWER RESOURCE_ENERGY */

import BodyBuilder from 'creep/body-builder';
import cache from 'utils/cache';
Severity: Minor
Found in src/spawn-role/brawler.ts - About 3 hrs to fix

    OperatorRole has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class OperatorRole extends Role {
        creep: PowerCreep;
    
        /**
         * Makes a power creep behave like an operator.
    Severity: Minor
    Found in src/role/power-creep/operator.ts - About 3 hrs to fix

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

          getCreepBody(room: Room): BodyPartConstant[] {
              return (new BodyBuilder())
                  .setWeights({[CARRY]: 3, [WORK]: 2})
                  .setEnergyLimit(Math.min(room.energyCapacityAvailable, Math.max(room.energyCapacityAvailable * 0.9, room.energyAvailable)))
                  .build();
      Severity: Major
      Found in src/spawn-role/reclaim.ts and 1 other location - About 3 hrs to fix
      src/spawn-role/harvester.deposit.ts on lines 98..103

      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

          getCreepBody(room: Room): BodyPartConstant[] {
              return (new BodyBuilder())
                  .setWeights({[CARRY]: 3, [WORK]: 2})
                  .setEnergyLimit(Math.min(room.energyCapacityAvailable, Math.max(room.energyCapacityAvailable * 0.9, room.energyAvailable)))
                  .build();
      Severity: Major
      Found in src/spawn-role/harvester.deposit.ts and 1 other location - About 3 hrs to fix
      src/spawn-role/reclaim.ts on lines 144..149

      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 performPickup has 82 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          performPickup(creep: RelayHaulerCreep) {
              creep.say('p0');
              const sourcePosition = decodePosition(creep.memory.source);
              if (!sourcePosition) {
                  creep.say('newtar');
      Severity: Major
      Found in src/role/hauler.relay.ts - About 3 hrs to fix

        Function performRemoteHarvest has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            performRemoteHarvest(creep: RemoteHarvesterCreep) {
                if (creep.pos.roomName !== creep.operation.getRoom()) return;
        
                // Check if a container nearby is in need of repairs, since we can handle
                // it with less intents than haulers do.
        Severity: Minor
        Found in src/role/harvester.remote.ts - About 3 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

        Function attackMilitaryTarget has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            attackMilitaryTarget(creep: BrawlerCreep, target: Creep | AnyStructure) {
                if (target instanceof StructureController) {
                    if (target.owner && creep.attackController(target) === OK) {
                        return true;
                    }
        Severity: Minor
        Found in src/role/brawler.ts - About 3 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

        Function getStoredEnergy has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        Room.prototype.getStoredEnergy = function (this: Room) {
            return cache.inObject(this, 'storedEnergy', 1, () => {
                let total = this.getCurrentResourceAmount(RESOURCE_ENERGY);
        
                // Add energy on storage location (pre storage).
        Severity: Minor
        Found in src/prototype/room.resources.ts - About 3 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

        Function getDamageCapacity has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

        Creep.prototype.getDamageCapacity = function (this: Creep, range) {
            // @todo Cache for one tick?
            let total = 0;
            if (range > 3) return total;
        
        
        Severity: Minor
        Found in src/prototype/creep.military.ts - About 3 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

        Function addClaimerSpawnOptions has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
        Open

            addClaimerSpawnOptions(room: Room, options: RemoteMiningSpawnOption[]) {
                if (options.length > 0) return;
        
                // Only spawn claimers if they can have 2 or more claim parts.
                // @todo We could even do it with 1 part if the controller has multiple
        Severity: Minor
        Found in src/spawn-role/remote-mining.ts - About 3 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

            getRangedCreepBody(room: Room): BodyPartConstant[] {
                return (new BodyBuilder())
                    .setWeights({[RANGED_ATTACK]: 1})
                    .setEnergyLimit(Math.min(room.energyCapacityAvailable, Math.max(room.energyCapacityAvailable * 0.9, room.energyAvailable)))
                    .setMoveBufferRatio(0.4)
        Severity: Major
        Found in src/spawn-role/brawler.ts and 1 other location - About 3 hrs to fix
        src/spawn-role/brawler.ts on lines 362..368

        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 100.

        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