Skip to content

Commit

Permalink
Tests code coverage and code climate config v2 (#41)
Browse files Browse the repository at this point in the history
* tests code coverage
* code climate config v2
* function keyword removed
* yarn.lock updated
* node_js lts in travis.yml
  • Loading branch information
programmer4web authored and plequang committed Mar 12, 2018
1 parent ab6b66b commit e1afa61
Show file tree
Hide file tree
Showing 10 changed files with 1,531 additions and 747 deletions.
61 changes: 42 additions & 19 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,51 @@
---
engines:
version: "2"
checks:
argument-count:
enabled: true
config:
threshold: 4
complex-logic:
enabled: true
config:
threshold: 4
file-lines:
enabled: true
config:
threshold: 250
method-complexity:
enabled: true
config:
threshold: 5
method-count:
enabled: true
config:
threshold: 20
method-lines:
enabled: true
config:
threshold: 30
nested-control-flow:
enabled: true
config:
threshold: 4
return-statements:
enabled: true
config:
threshold: 4
similar-code:
enabled: true
identical-code:
enabled: true

plugins:
eslint:
enabled: true
channel: "eslint-4"
checks:
complexity:
enabled: false
config:
sanitize_batch: false
extensions:
- .js
- .html

duplication:
enabled: true
config:
languages:
javascript:
mass_threshold: 50

- .js
- .html
fixme:
enabled: true

ratings:
paths:
- "**.js"
- "**.html"
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/bower_components-1.x/*
/coverage/
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ bower_components/
bower_components-1.x/
bower-1.x.json
node_modules/
coverage/
debug.log
yarn-error.log
.eslintcache
.DS_Store
26 changes: 17 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
language: node_js
node_js: 6
node_js: "lts/*"
dist: trusty
sudo: required
env:
global:
- CC_TEST_REPORTER_ID=9798015be3ef64095a2bacb1046d8c981f8bd35e40fda757c431366e786ef566
addons:
firefox: latest
apt:
sources:
- google-chrome
- google-chrome
packages:
- google-chrome-stable
- google-chrome-stable
cache:
yarn: true
directories:
- node_modules
- bower_components
- bower_components-1.x
- ".eslintcache"
- "$HOME/.cache/bower"
- node_modules
- bower_components
- bower_components-1.x
- ".eslintcache"
- "$HOME/.cache/bower"
before_script:
- yarn run lint
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
- yarn run lint
script:
- xvfb-run yarn test
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
notifications:
slack:
secure: CDiBhqBBuAVuia0kDJNzNLIZ4tdN4ngEjZ+0RfEuY8Yusgllc0EHw/WcN+rNCg+tOMR2mOz0c0FDIbhariZV1yOW6zoJOXga3EpP7dkbyStog+oUIolHBhk3dFb90DpzjrNO2GhsPPcRpbvxY+0bK0u75bydWvnj7rxCWt73ZHHIZsoYjBZq7MV0doiSbY3hyHD/lNhB+fVU28lIV6NovGVJCp9GuYSB4P+HKQsdLmzhzYlYQZoDwW5ZLQraEDMJRu9YLIZfPRFF/G/qO5L0xrp18sqihPSa8Pqy6Yhz81aoyZxyI5/CVXcIUBlw+s2HfTOjzIYPuTOYlSaH47ua2QIQZ9+5reJ6guhCXGguj3QoDx+wXelOB4UI/Ghe8Txh73V429rwjPyH/dKkAIA/yyP1Y5zDxDyynUN8EAnmyLkySqwfffU4VVud3hxO2/QUbIwjKSFwuFz1zJCNUT3K0D5ESKDGXJeaSq7bdfh0cRTA4E9FX29gt6eq5g0aVwb9HwAMlY0xjVum8Tb9QFu37EEOq/8HDlHUg+yOx7IvZSRQK0VRSpQ+mOlwd0nfV42sMHpPS0HQ2FgQsc0485FmhzdG2Q0PQPybGn2DzQo8lv4KAg3se/TwQEwKQASm5vxAvhJasMceXfn/9EFrRZmNO2T6YZLCtO4wt63JAeo6CUQ=
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"iron-component-page": "PolymerElements/iron-component-page#1 - 3",
"iron-demo-helpers": "PolymerElements/iron-demo-helpers#1 - 2",
"iron-test-helpers": "PolymerElements/iron-test-helpers#1 - 2",
"web-component-tester": "^6.0.0",
"web-component-tester": "^6.5.0",
"iron-list": "PolymerElements/iron-list#1 - 2",
"web-animations-js": "web-animations/web-animations-js#^2.2",
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0"
Expand Down
8 changes: 4 additions & 4 deletions cosmoz-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
return this.disabled || this.hidden;
},

_onResize: function () {
_onResize() {
// HACK(pasleq): Can't explain why, but under Chrome 62, we've experienced disappearing content
// the tab content is scolled. This hack seems to fix this issue.
var scrollTop = this.$.content.scrollTop;
Expand All @@ -92,7 +92,7 @@
* @param {Array} items Array of selectable items
* @returns {Boolean} True if items is not empty
*/
_computeHasCards: function (items = this.items) {
_computeHasCards(items = this.items) {
return items && items.length > 0;
},

Expand All @@ -104,7 +104,7 @@
* @param {Boolean} isSelected The isSelected property
* @returns {Boolean} True if `hasCards` or `isSelected`
*/
_computeOpened: function (accordion, hasCards = this.hasCards, isSelected = this.isSelected) {
_computeOpened(accordion, hasCards = this.hasCards, isSelected = this.isSelected) {
return !accordion || hasCards || isSelected;
},

Expand All @@ -118,7 +118,7 @@
* @return {void}
*/
_notifyProperty: function (property, value) {
_notifyProperty(property, value) {
this.fire('tab-property-changed', {
property: property,
value: value,
Expand Down
22 changes: 11 additions & 11 deletions cosmoz-tabbable-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
selectedValues: {
type: Array,
notify: true,
value: function () {
value() {
return [];
}
},
Expand All @@ -78,7 +78,7 @@
type: Array,
readOnly: true,
notify: true,
value: function () {
value() {
return [];
}
}
Expand All @@ -101,7 +101,7 @@
* @param {Boolean} accordion The `accordion` property
* @returns {Boolean} True if accordion is true
*/
_computeMulti: function (accordion) {
_computeMulti(accordion) {
return !!accordion;
},

Expand All @@ -113,7 +113,7 @@
* @param {Event} e The `cosmoz-tab-toggle` event
* @returns {void}
*/
_onToggleTab: function (e) {
_onToggleTab(e) {
var item = e.target,
index = this.items.indexOf(item),
value;
Expand All @@ -134,7 +134,7 @@
* @param {Array} items The items to forward property to
* @returns {void}
*/
_forwardProperty: function (property, value, items) {
_forwardProperty(property, value, items) {
items.forEach(function (item) {
item.set(property, value);
});
Expand All @@ -147,7 +147,7 @@
* @param {type} attr The attribute used to compute the value
* @returns {String|Number|void} The compute value
*/
_valueForItem: function (item, attr = this.attrForSelected) {
_valueForItem(item, attr = this.attrForSelected) {
if (!item) {
return;
}
Expand All @@ -171,7 +171,7 @@
* @fires 'tab-select'
* @return {void} description
*/
_onIronSelect: function (e, detail) {
_onIronSelect(e, detail) {
var item = detail.item,
index = this.items.indexOf(item),
opts = {node: item, bubbles: false };
Expand All @@ -187,17 +187,17 @@
}
},

_toggleSelected: function (value) {
_toggleSelected(value) {
Polymer.IronMultiSelectableBehaviorImpl._toggleSelected.call(this, this._normalizeValue(value));
},

_onTabActivate: function (e) {
_onTabActivate(e) {
if (this.multi && this.fallbackSelection !== null && this.selectedItems.length === 1 && this.selectedItems[0] === e.detail.item) {
e.preventDefault();
}
},

multiChanged: function (multi, old) {
multiChanged(multi, old) {
this._selection.multi = multi;

if (multi === true && old === false && this.selected !== null && this.selected !== undefined) {
Expand All @@ -208,7 +208,7 @@
this._updateSelected();
},

_normalizeValue: function (value) {
_normalizeValue(value) {
return this.attrForSelected ? value : isNaN(value) || value === null ? value : Number(value);
},

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"eslint": "^4.9.0",
"eslint-plugin-html": "^3.2.2",
"eslint-plugin-mocha": "^4.11.0",
"polymer-cli": "^1.5.7"
"polymer-cli": "^1.6.0",
"web-component-tester-istanbul": "Neovici/web-component-tester-istanbul"
},
"scripts": {
"start": "polymer serve -o",
Expand Down
17 changes: 16 additions & 1 deletion wct.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@
"plugins": {
"local": {
"browsers": ["chrome", "firefox"]
}
},
"istanbul": {
"dir": "./coverage",
"reporters": ["text-summary", "lcov"],
"include": [
"cosmoz-tab-card.html",
"cosmoz-tab-card.js",
"cosmoz-tab.html",
"cosmoz-tab.js",
"cosmoz-tabbable-behavior.html",
"cosmoz-tabbed-behavior.html",
"cosmoz-tabs.html",
"cosmoz-tabls.js"
],
"exclude": []
}
}
}
Loading

0 comments on commit e1afa61

Please sign in to comment.