Skip to content

Commit

Permalink
Miscellaneous small improvements
Browse files Browse the repository at this point in the history
* Bump version numbers
* Introduce JSCS style validation
* Address style failures
  • Loading branch information
andy-armstrong committed Nov 23, 2015
1 parent 582a4a4 commit aba4abd
Show file tree
Hide file tree
Showing 33 changed files with 1,185 additions and 1,203 deletions.
13 changes: 13 additions & 0 deletions .jscsrc
@@ -0,0 +1,13 @@
{
"preset": "google",

// edX specific rules
"validateIndentation": 4,
"maximumLineLength": 120,
"disallowMultipleVarDecl": false,
"requireCamelCaseOrUpperCaseIdentifiers": {"ignoreProperties": true},

// Temporary overrides until we clean up further...
"validateQuoteMarks": null, // We should standardize on single quotes
"disallowKeywordsOnNewLine": [] // Other repos disallow lines starting with "else"
}
6 changes: 0 additions & 6 deletions .jshintrc
Expand Up @@ -14,7 +14,6 @@
"forin" : true, // Requires all for in loops to filter object's items.
"freeze" : true, // Prohibits overwriting prototypes of native objects such as Array, Date and so on.
"immed" : true, // Prohibits the use of immediate function invocations without wrapping them in parentheses.
// "indent" : 4, // Enforces specific tab width for your code. Has no effect when "white" option is not used.
"latedef" : "nofunc", // Prohibits the use of a variable before it was defined. Setting this option to "nofunc" will allow function declarations to be ignored.
"newcap" : true, // Requires you to capitalize names of constructor functions.
"noarg" : true, // Prohibits the use of arguments.caller and arguments.callee.
Expand All @@ -27,11 +26,6 @@
"unused" : true, // Warns when you define and never use your variables.
"strict" : false, // Requires all functions to run in ECMAScript 5's strict mode.
"trailing" : true, // Makes it an error to leave a trailing whitespace in your code.
"maxlen" : 120, // Lets you set the maximum length of a line.
//"maxparams" : 4, // Lets you set the max number of formal parameters allowed per function.
//"maxdepth" : 4, // Lets you control how nested do you want your blocks to be.
//"maxstatements" : 4, // Lets you set the max number of statements allowed per function.
//"maxcomplexity" : 4, // Lets you control cyclomatic complexity throughout your code.


// == Relaxing Options ================================================
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Expand Up @@ -21,7 +21,6 @@ install-python:
./scripts/install-python.sh

install-js:
npm config set loglevel warn
npm install

install-nltk-data:
Expand All @@ -43,6 +42,7 @@ install-test:
pip install -q -r requirements/test.txt

install-sys-requirements: install-system install-node
npm config set loglevel warn

install-dev:
gem install sass
Expand All @@ -52,9 +52,12 @@ install: install-wheels install-python install-js install-nltk-data install-test

quality:
jshint openassessment/xblock/static/js/src -c .jshintrc --verbose
./node_modules/jscs/bin/jscs openassessment/xblock/static/js/src --verbose

test: quality
./scripts/test.sh
test: quality test-python test-js

test-python:
./scripts/test-python.sh

render-templates:
./scripts/render-templates.sh
Expand All @@ -65,6 +68,8 @@ test-js: render-templates
test-js-debug: render-templates
./scripts/js-debugger.sh

test-sandbox: test-acceptance test-a11y

test-acceptance:
./scripts/test-acceptance.sh tests

Expand Down
4 changes: 2 additions & 2 deletions openassessment/xblock/static/js/spec/lms/oa_container.js
Expand Up @@ -2,7 +2,7 @@
Tests for the Openassessment Container Object.
**/

describe("OpenAssessment.Container", function () {
describe("OpenAssessment.Container", function() {

var counter = 0;
var StubContainerItem = function(element) {
Expand Down Expand Up @@ -38,7 +38,7 @@ describe("OpenAssessment.Container", function () {
);
};

beforeEach(function () {
beforeEach(function() {
// Reset the counter before each test
counter = 0;

Expand Down
Expand Up @@ -174,7 +174,7 @@ describe("OpenAssessment edit assessment views", function() {
});

it("enables and disables", function() { testEnableAndDisable(view); });
it("loads a description", function () {
it("loads a description", function() {
// This assumes a particular structure of the DOM,
// which is set by the HTML fixture.
expect(view.description()).toEqual({
Expand All @@ -192,7 +192,7 @@ describe("OpenAssessment edit assessment views", function() {
});
});

it("modifies a description", function () {
it("modifies a description", function() {
view.exampleContainer.add();
expect(view.description()).toEqual({
examples: [
Expand Down
Expand Up @@ -429,7 +429,7 @@ describe("OpenAssessment.StudentTrainingListenerWithTrainingExamples", function(
});


it("adds a criterion and an option, then adds a training example", function (){
it("adds a criterion and an option, then adds a training example", function(){
// Initial state, set by the fixture
assertExampleLabels(
listener.examplesOptionsLabels(),
Expand Down
Expand Up @@ -208,7 +208,7 @@ describe("OpenAssessment.EditRubricView", function() {
});
});

it("validates option points", function () {
it("validates option points", function() {
// Test that a particular value is marked as valid/invalid
var testValidateOptionPoints = function(value, isValid) {
var option = view.getOptionItem(0, 0);
Expand Down
7 changes: 3 additions & 4 deletions openassessment/xblock/static/js/src/lms/oa_base.js
Expand Up @@ -27,7 +27,6 @@ OpenAssessment.BaseView = function(runtime, element, server, data) {
this.staffAreaView = new OpenAssessment.StaffAreaView(this.element, this.server, this);
};


OpenAssessment.BaseView.prototype = {

/**
Expand All @@ -39,7 +38,7 @@ OpenAssessment.BaseView.prototype = {
*/
scrollToTop: function() {
if ($.scrollTo instanceof Function) {
$(window).scrollTo($("#openassessment__steps", this.element), 800, {offset:-50});
$(window).scrollTo($("#openassessment__steps", this.element), 800, {offset: -50});
}
},

Expand All @@ -49,8 +48,8 @@ OpenAssessment.BaseView.prototype = {
Args:
parentSel (JQuery selector): CSS selector for the container element.
**/
setUpCollapseExpand: function (parentSel) {
parentSel.on('click', '.ui-toggle-visibility__control', function (eventData) {
setUpCollapseExpand: function(parentSel) {
parentSel.on('click', '.ui-toggle-visibility__control', function(eventData) {
var sel = $(eventData.target).closest('.ui-toggle-visibility');
sel.toggleClass('is--collapsed');
}
Expand Down
1 change: 0 additions & 1 deletion openassessment/xblock/static/js/src/lms/oa_grade.js
Expand Up @@ -15,7 +15,6 @@ OpenAssessment.GradeView = function(element, server, baseView) {
this.baseView = baseView;
};


OpenAssessment.GradeView.prototype = {
/**
Load the grade view.
Expand Down
3 changes: 1 addition & 2 deletions openassessment/xblock/static/js/src/lms/oa_leaderboard.js
Expand Up @@ -15,7 +15,6 @@ OpenAssessment.LeaderboardView = function(element, server, baseView) {
this.baseView = baseView;
};


OpenAssessment.LeaderboardView.prototype = {
/**
Load the leaderboard view.
Expand All @@ -32,5 +31,5 @@ OpenAssessment.LeaderboardView.prototype = {
).fail(function(errMsg) {
baseView.showLoadError('leaderboard', errMsg);
});
},
}
};
2 changes: 1 addition & 1 deletion openassessment/xblock/static/js/src/lms/oa_message.js
Expand Up @@ -31,5 +31,5 @@ OpenAssessment.MessageView.prototype = {
).fail(function(errMsg) {
baseView.showLoadError('message', errMsg);
});
}
}
};
3 changes: 1 addition & 2 deletions openassessment/xblock/static/js/src/lms/oa_peer.js
Expand Up @@ -16,7 +16,6 @@ OpenAssessment.PeerView = function(element, server, baseView) {
this.rubric = null;
};


OpenAssessment.PeerView.prototype = {

/**
Expand Down Expand Up @@ -184,7 +183,7 @@ OpenAssessment.PeerView.prototype = {
Common peer assessment request building, used for all types of peer assessments.
Args:
successFunction (function): The function called if the request is
successfunction(function): The function called if the request is
successful. This varies based on the type of request to submit
a peer assessment.
Expand Down

0 comments on commit aba4abd

Please sign in to comment.