engagementgamelab/CivicSeed

View on GitHub

Showing 421 of 421 total issues

Function init has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  init: function (callback) {
    // Get all resources
    var npcs = $game.$npc.getNpcData()

    $.each(npcs, function (key, npc) {
Severity: Minor
Found in client/code/game/game.resources.js - About 35 mins 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 idle has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  idle: function () {
    _counter += 1

    if (_botanist.renderInfo.srcY === 0) {
      if (_counter >= 24) {
Severity: Minor
Found in client/code/game/game.botanist.js - About 35 mins 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 loadTilesheets has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  loadTilesheets: function (num) {
    var path = CivicSeed.CLOUD_PATH + '/img/game/'
    var ext = '.png'

    // load the images recursively until done
Severity: Minor
Found in client/code/game/game.render.js - About 35 mins 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

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

    if (x > trash.left && x < trash.right && y > trash.top && y < trash.bottom) {
      trashEl.classList.add('active')
      trashing = true
    } else {
      trashEl.classList.remove('active')
Severity: Minor
Found in client/code/game/game.botanist.js and 1 other location - About 35 mins to fix
client/code/game/game.botanist.js on lines 1024..1030

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

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

      Npc.find({ id: npcId }, function (err, npc) {
        if (err) {
          winston.error('Could not find NPC: %s  '.red.inverse, err)
        } else {
          res(npc)
Severity: Minor
Found in server/rpc/game/npc.js and 1 other location - About 35 mins to fix
server/rpc/game/npc.js on lines 24..30

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

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

    if (x > trash.left && x < trash.right && y > trash.top && y < trash.bottom) {
      $('.br' + d.id).remove()
      $('.r' + d.id)
        .css('opacity', 1)
        .attr('draggable', 'true')
Severity: Minor
Found in client/code/game/game.botanist.js and 1 other location - About 35 mins to fix
client/code/game/game.botanist.js on lines 993..999

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

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

      tileModel
        .where('x').equals(position.x)
        .where('y').equals(position.y)
        .find(function (err, tiles) {
          if (err) {
Severity: Major
Found in server/rpc/admin/npcs.js and 3 other locations - About 35 mins to fix
server/rpc/admin/npcs.js on lines 18..39
server/rpc/admin/npcs.js on lines 69..106
server/rpc/admin/npcs.js on lines 83..99

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

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

                    tileModel
                      .where('x').equals(oldPosition.x)
                      .where('y').equals(oldPosition.y)
                      .find(function (err, oldTiles) {
                        if (err) {
Severity: Major
Found in server/rpc/admin/npcs.js and 3 other locations - About 35 mins to fix
server/rpc/admin/npcs.js on lines 18..39
server/rpc/admin/npcs.js on lines 43..61
server/rpc/admin/npcs.js on lines 69..106

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

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

      tileModel
        .where('x').equals(position.x)
        .where('y').equals(position.y)
        .find(function (err, tiles) {
          if (err) {
Severity: Major
Found in server/rpc/admin/npcs.js and 3 other locations - About 35 mins to fix
server/rpc/admin/npcs.js on lines 43..61
server/rpc/admin/npcs.js on lines 69..106
server/rpc/admin/npcs.js on lines 83..99

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

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

        tileModel
          .where('x').equals(newPosition.x)
          .where('y').equals(newPosition.y)
          .find(function (err, newTiles) {
            if (err) {
Severity: Major
Found in server/rpc/admin/npcs.js and 3 other locations - About 35 mins to fix
server/rpc/admin/npcs.js on lines 18..39
server/rpc/admin/npcs.js on lines 43..61
server/rpc/admin/npcs.js on lines 83..99

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

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

      Npc.find(function (err, npcs) {
        if (err) {
          winston.error('Could not find NPCs: %s  '.red.inverse, err)
        } else {
          res(npcs)
Severity: Minor
Found in server/rpc/game/npc.js and 1 other location - About 35 mins to fix
server/rpc/game/npc.js on lines 14..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 46.

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

Avoid too many return statements within this function.
Open

    else if (diffX < 0 && diffY > 0) return 3
Severity: Major
Found in client/code/game/game.player.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        else return -1
    Severity: Major
    Found in client/code/game/game.player.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            if (!found) return false
      Severity: Major
      Found in client/code/game/game.botanist.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

              if (aStack[length] == a) return bStack[length] == b;
        Severity: Major
        Found in client/code/system/underscore.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return -1;
          Severity: Major
          Found in client/code/system/underscore.js - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return false;
            Severity: Major
            Found in client/code/system/underscore.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return result;
              Severity: Major
              Found in client/code/system/underscore.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      default: while (++i < l) (ev = events[i]).callback.apply(ev.ctx, args); return;
                Severity: Major
                Found in client/code/system/backbone.js - About 30 mins to fix

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

                    alert: function (message) {
                      $game.statusUpdate({
                        message: message,
                        input: 'status',
                        screen: true,
                  Severity: Minor
                  Found in client/code/game/game.main.js and 2 other locations - About 30 mins to fix
                  client/code/game/game.main.js on lines 352..359
                  client/code/game/game.main.js on lines 362..369

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

                  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