Skip to content

Commit

Permalink
Added sonar code quality checks
Browse files Browse the repository at this point in the history
  • Loading branch information
rheh committed Apr 15, 2013
1 parent 128606a commit e9493e7
Show file tree
Hide file tree
Showing 16 changed files with 129 additions and 9 deletions.
Binary file added bounce/jstestdriver/JsTestDriver-1.3.5.jar
Binary file not shown.
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?><testsuite name="Chrome_260141043_Windows.bounceTest" errors="0" failures="0" tests="1" time="0.004">
<testcase classname="Chrome_260141043_Windows.bounceTest" name="testImageLoaded" time="0.004"/>
</testsuite>
Binary file added bounce/jstestdriver/coverage-1.3.5.jar
Binary file not shown.
11 changes: 11 additions & 0 deletions bounce/jstestdriver/jsTestDriver.conf
@@ -0,0 +1,11 @@
server: http://localhost:9876

load:
- ../sources/*.js
test:
- ../tests/*.js

plugin:
- name: "coverage"
jar: "coverage-1.3.5.jar"
module: "com.google.jstestdriver.coverage.CoverageModule"
73 changes: 73 additions & 0 deletions bounce/jstestdriver/jsTestDriver.conf-coverage.dat
@@ -0,0 +1,73 @@
SF:C:\xampp\htdocs\www2.html5.co.uk\bounce\tests\bounceTest.js
DA:6,1
DA:9,1
DA:10,1
end_of_record
SF:C:\xampp\htdocs\www2.html5.co.uk\bounce\sources\bounce.js
DA:2,1
DA:7,1
DA:8,1
DA:11,1
DA:12,1
DA:18,0
DA:23,1
DA:25,0
DA:28,1
DA:29,0
DA:30,0
DA:31,0
DA:32,0
DA:33,0
DA:37,1
DA:38,0
DA:96,1
DA:97,0
DA:98,0
DA:101,1
DA:102,0
DA:106,0
DA:107,0
DA:108,0
DA:111,0
DA:114,1
DA:116,1
DA:117,1
DA:118,1
DA:121,1
DA:122,0
DA:123,0
DA:124,0
DA:125,0
end_of_record
SF:C:\xampp\htdocs\www2.html5.co.uk\bounce\sources\letter.js
DA:1,1
DA:2,0
DA:3,0
DA:4,0
DA:5,0
DA:6,0
DA:7,0
DA:8,0
DA:9,0
DA:10,0
DA:11,0
DA:12,0
DA:13,0
DA:14,0
DA:15,0
DA:16,0
DA:23,0
DA:24,0
DA:25,0
DA:27,0
DA:28,0
DA:29,0
DA:31,0
DA:32,0
DA:33,0
DA:34,0
DA:35,0
DA:38,0
DA:39,0
DA:40,0
end_of_record
2 changes: 2 additions & 0 deletions bounce/run-sonar.bat
@@ -0,0 +1,2 @@
sonar-runner.bat -Dproject.settings=sonar.properties
pause
1 change: 1 addition & 0 deletions bounce/runTest.bat
@@ -0,0 +1 @@
java -jar jstestdriver/JsTestDriver-1.3.5.jar --port 9876 --tests all --browser "C:\Users\TESTING\AppData\Local\Google\Chrome\Application\chrome.exe" --testOutput jstestdriver --config jstestdriver/jsTestDriver.conf
21 changes: 21 additions & 0 deletions bounce/sonar.properties
@@ -0,0 +1,21 @@

# required metadata
sonar.projectKey=HTML5Canvas:bounce
sonar.projectName=Bounce
sonar.projectVersion=1.1

# path to source directories (required)
sources=sources/

# optional comma-separated list of paths to libraries. Only path to JAR file and path to directory of classes are supported.
libraries=

# Uncomment this line to analyse a project which is not a java project.
# The value of the property must be the key of the language.
sonar.language=js

tests=tests/

# Advanced parameters
sonar.javascript.jstestdriver.reportsfolder=jstestdriver
sonar.dynamicAnalysis=reuseReportss
File renamed without changes
8 changes: 4 additions & 4 deletions bounce/bounce.js → bounce/sources/bounce.js
Expand Up @@ -5,7 +5,6 @@ var canvas = null,
bg = null;

(function () {

"use strict";
// this function is strict...
// RequestAnimFrame: a browser API for getting smooth animations
Expand All @@ -19,7 +18,6 @@ var canvas = null,
window.setTimeout(callback, 1000 / 60);
};
})();

}());

function clearCanvas() {
Expand Down Expand Up @@ -120,8 +118,10 @@ function loadBackground(callback) {
bg.onload = callback;
}

window.addEventListener('load', function (ev) {
window.addEventListener('load', function () {
canvas = document.getElementById('canvas');
ctx = canvas.getContext('2d');
loadBackground(function() { setUpBalls(); });
loadBackground(function() {
setUpBalls();
});
}, false);
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
6 changes: 1 addition & 5 deletions bounce/letter.js → bounce/sources/letter.js
Expand Up @@ -12,7 +12,6 @@ var Letter = function (x, bg, ballSettings) {
this.bg = bg;
this.bounceFactor = ballSettings.factor;
this.bounces = 0;

this.draw = function () {
ctx.drawImage(this.bg,
this.imagex, this.imagey,
Expand All @@ -21,18 +20,15 @@ var Letter = function (x, bg, ballSettings) {
this.width, this.height
);
};

this.impact = function () {
this.vy = this.vyAdjust;
this.bounces++;
};

this.move = function () {
this.y += this.vy;
this.vy += 0.25; //gravity;
this.vy += 0.25; //gravity
// Bounce the ball when it hits the bottom
if(this.bounces > 1) {

if ((this.y + this.height) > canvas.height + 200) {
this.bounces = 0;
this.vyAdjust = -13;
Expand Down
13 changes: 13 additions & 0 deletions bounce/tests/bounceTest.js
@@ -0,0 +1,13 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

TestCase('bounceTest', {

testImageLoaded : function() {
loadBackground();
assertTrue(typeof bg !== "undefined");
}

});

0 comments on commit e9493e7

Please sign in to comment.