From a3fa2b6aa8059a8f8b9728ce66196a47c23759e9 Mon Sep 17 00:00:00 2001 From: xcatliu Date: Tue, 5 Dec 2017 12:02:45 +0800 Subject: [PATCH] Fix coveralls --- src/ComplexityChecker/index.js | 12 +++--------- .../integration/checkUnsupportedFiletype.test.js | 16 ++++++++++++++++ test/sample/hello.java | 8 ++++++++ 3 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 test/integration/checkUnsupportedFiletype.test.js create mode 100644 test/sample/hello.java diff --git a/src/ComplexityChecker/index.js b/src/ComplexityChecker/index.js index 942252d..3722227 100644 --- a/src/ComplexityChecker/index.js +++ b/src/ComplexityChecker/index.js @@ -71,7 +71,9 @@ class ComplexityChecker extends BaseChecker { return { filepath: resolvedFilepath, complexity: 0, - details: [] + details: [], + numberOfFunctions: 0, + numberOfHighComplexityFunctions: 0 }; } @@ -109,14 +111,6 @@ class ComplexityChecker extends BaseChecker { } return 0; } - getPercentage(count) { - let result = 0; - if (this.fileList.length > 0) { - result = count / this.fileList.length * 100; - } - result = result.toFixed(2); - return result; - } } module.exports = ComplexityChecker; diff --git a/test/integration/checkUnsupportedFiletype.test.js b/test/integration/checkUnsupportedFiletype.test.js new file mode 100644 index 0000000..428489f --- /dev/null +++ b/test/integration/checkUnsupportedFiletype.test.js @@ -0,0 +1,16 @@ +const assert = require('chai').assert; + +const CodeQualityChecker = require('../../'); +const codeQualityChecker = new CodeQualityChecker(); + +describe('Check unsupported filetype', () => { + const cqcResult = codeQualityChecker.check([ + 'test/sample/hello.java' + ]); + it('should have correct result', () => { + assert.equal(cqcResult.base.numberOfFiles, 1); + assert.equal(cqcResult.sloc.source, 5); + assert.equal(cqcResult.jscpd.percentage, '0.00'); + assert.equal(cqcResult.complexity.percentage, '0.00'); + }); +}); diff --git a/test/sample/hello.java b/test/sample/hello.java new file mode 100644 index 0000000..6634e98 --- /dev/null +++ b/test/sample/hello.java @@ -0,0 +1,8 @@ +public class HelloWorld { + + public static void main(String[] args) { + // Prints "Hello, World" to the terminal window. + System.out.println("Hello, World"); + } + +} \ No newline at end of file