Skip to content

Static Analysis

Christopher Conte edited this page Dec 3, 2016 · 15 revisions

All Static Analyzer Output:

####InvestPhase.js JSLint Output (Problems)

7 Combine this with the previous 'var' statement. var level = config.level;

9 Combine this with the previous 'var' statement. var opportunityToNext = 100;

10 Combine this with the previous 'var' statement. var dead = false;

11 Combine this with the previous 'var' statement. var begin = false;

12 Combine this with the previous 'var' statement. var advance = false;

13 Combine this with the previous 'var' statement. var dictionary = [

47 Combine this with the previous 'var' statement. var currentWord = dictionary[0];

49 Combine this with the previous 'var' statement. var ip = {};

106 'module' was used before it was defined. module.exports = HuntPhase;


####HuntPhase.js JSLint Output (Problems)

Combine this with the previous 'var' statement. var beginTime = 0;

9 Combine this with the previous 'var' statement. var finished = false;

10 Combine this with the previous 'var' statement. var begin = false;

11 Combine this with the previous 'var' statement. var stockPrice = Math.random() * 300;

12 Combine this with the previous 'var' statement. var stockCount = 0;

14 Combine this with the previous 'var' statement. var ip = {};

34 Combine this with the previous 'var' statement. var newPrice = Math.abs(stockPrice + delta);

83 'module' was used before it was defined. module.exports = InvestPhase;


####io.js

1 'module' was used before it was defined. module.exports =

4 Missing 'use strict' statement. var util = require('util');

4 'require' was used before it was defined. var util = require('util');

5 Combine this with the previous 'var' statement. var GameController = require('./../models/GameController');

6 Combine this with the previous 'var' statement. var IP = require('./../models/InvestPhase');

7 Combine this with the previous 'var' statement. var HP = require('./../models/HuntPhase');

9 Combine this with the previous 'var' statement. var assert = require('assert');

10 Combine this with the previous 'var' statement. var async = require('async');

11 Combine this with the previous 'var' statement. var redis = require('redis');

12 Combine this with the previous 'var' statement. var Leaderboard = require('leaderboard');


####GameController.js

1 Expected exactly one space between 'function' and '('. (function() {

2 Missing 'use strict' statement. var InvestPhase = require('./InvestPhase');

2 'require' was used before it was defined. var InvestPhase = require('./InvestPhase');

3 Combine this with the previous 'var' statement. var HuntPhase = require('./HuntPhase');

5 Combine this with the previous 'var' statement. var GameController = function(config) {

8 Combine this with the previous 'var' statement. var name = config.name || 'Player';

10 Combine this with the previous 'var' statement. var score = 0;

11 Combine this with the previous 'var' statement. var level = 1;

12 Combine this with the previous 'var' statement. var wallet = 5000;

13 Combine this with the previous 'var' statement. var phase = null;

14 Combine this with the previous 'var' statement. var phaseName = '';

15 Combine this with the previous 'var' statement. var isDead = false;

17 Combine this with the previous 'var' statement. var gc = { };

54 Expected ';' and instead saw 'gc'. }

94 Expected exactly one space between 'function' and '('. gc.die = function() {

103 Expected ';' and instead saw 'gc'. }

145 Expected '=' at column 7, not column 21. return wallet = value;

As with any LINTer there are always issues which one may choose to ignore, for the sake of following a specific convention within our chosen style guide. JSLINT complains about our use of multiple var statements, where they could be combined into one. However the node.js style guide we follow (https://github.com/felixge/node-style-guide) says to not use a single var. While it does sacrifice concision, it facilitates reordering of code. It also looks a little cleaner because the variable names all start on the same column and are thus easier to read. As well with the syntax of node.js our LINTer was very active in trying to enforce laws that didn't apply or otherwise would take us away from proper coding conventions. For example in our module declarations they look similar enough to normal ones that our LINTer was enforcing semicolons: Expected ';' and instead saw 'gc' where optional semicolons are typically required and are so in our style guide. Javascript will compile the same with or without those semicolons, however we think that semicolons are best left universal for the sake of consistency. Further, JSLINT guesses at things that could cause compilation errors, or have unreached values, but occasionally gets them wrong.

Clone this wiki locally