1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

Merge pull request #194 from oceanprotocol/feature/codeclimate

add code climate
This commit is contained in:
Matthias Kretschmann 2019-09-10 10:11:45 +02:00 committed by GitHub
commit 7d911bf763
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 59 deletions

View File

@ -38,6 +38,9 @@ before_install:
- echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
before_script:
- 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
- git clone https://github.com/oceanprotocol/barge
- cd barge
- bash -x start_ocean.sh --no-pleuston 2>&1 > start_ocean.log &
@ -53,6 +56,13 @@ script:
- npm run test:e2e || travis_terminate 1
- ./scripts/build.sh
# Pipe the coverage data to Code Climate
after_script:
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.client.json client/coverage/lcov.info # Format client coverage
- ./cc-test-reporter format-coverage -t lcov -o coverage/codeclimate.server.json server/coverage/lcov.info # Format server coverage
- ./cc-test-reporter sum-coverage coverage/codeclimate.*.json -p 2 # Sum both coverage parts into coverage/codeclimate.json
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then ./cc-test-reporter upload-coverage; fi # Upload coverage/codeclimate.json
notifications:
email: false

View File

@ -8,6 +8,8 @@
[![Build Status](https://travis-ci.com/oceanprotocol/commons.svg?branch=master)](https://travis-ci.com/oceanprotocol/commons)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6a19987e62344b1c9c1d5bc9f315c733)](https://www.codacy.com/app/ocean-protocol/commons)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/6a19987e62344b1c9c1d5bc9f315c733)](https://www.codacy.com/app/ocean-protocol/commons)
[![Maintainability](https://api.codeclimate.com/v1/badges/ed6e8212a8d294b6aa88/maintainability)](https://codeclimate.com/github/oceanprotocol/commons/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/ed6e8212a8d294b6aa88/test_coverage)](https://codeclimate.com/github/oceanprotocol/commons/test_coverage)
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square)](https://github.com/prettier/prettier)
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
[![css bigchaindb](https://img.shields.io/badge/css-bigchaindb-39BA91.svg)](https://github.com/bigchaindb/stylelint-config-bigchaindb)

View File

@ -10,6 +10,8 @@ export default class AssetsUser extends PureComponent<
{ list?: boolean; recent?: number },
{ results: any[]; isLoading: boolean }
> {
public static contextType = User
public state = { results: [], isLoading: true }
public _isMounted = false
@ -58,9 +60,12 @@ export default class AssetsUser extends PureComponent<
public render() {
const { account } = this.context
const { recent, list } = this.props
const { isLoading, results } = this.state
if (!account) return null
return (
account && (
<div className={styles.assetsUser}>
{this.props.recent && (
<h2 className={styles.subTitle}>
@ -68,26 +73,21 @@ export default class AssetsUser extends PureComponent<
</h2>
)}
{this.state.isLoading ? (
{isLoading ? (
<Spinner />
) : this.state.results.length ? (
) : results.length ? (
<>
{this.state.results
.slice(
0,
this.props.recent
? this.props.recent
: undefined
)
{results
.slice(0, recent || undefined)
.filter(asset => !!asset)
.map((asset: any) => (
<AssetTeaser
list={this.props.list}
list={list}
key={asset.id}
asset={asset}
/>
))}
{this.props.recent && (
{recent && (
<Link className={styles.link} to="/history">
All Data Sets
</Link>
@ -101,8 +101,5 @@ export default class AssetsUser extends PureComponent<
)}
</div>
)
)
}
}
AssetsUser.contextType = User

View File

@ -7,23 +7,24 @@ const cleanupContentType = (contentType: string) => {
let contentTypeCleaned
// TODO: add all the possible archive & compression MIME types
if (
contentType === 'application/x-lzma' ||
contentType === 'application/x-xz' ||
contentType === 'application/x-tar' ||
contentType === 'application/x-gtar' ||
contentType === 'application/x-bzip2' ||
contentType === 'application/x-gzip' ||
contentType === 'application/x-7z-compressed' ||
contentType === 'application/x-rar-compressed' ||
contentType === 'application/x-zip-compressed' ||
contentType === 'application/x-apple-diskimage'
) {
switch (contentType) {
case 'application/x-lzma':
case 'application/x-xz':
case 'application/x-tar':
case 'application/x-gtar':
case 'application/x-bzip2':
case 'application/x-gzip':
case 'application/x-7z-compressed':
case 'application/x-rar-compressed':
case 'application/x-zip-compressed':
case 'application/x-apple-diskimage':
contentTypeCleaned = contentTypeSplit
.replace('x-', '')
.replace('-compressed', '')
} else {
break
default:
contentTypeCleaned = contentTypeSplit
break
}
// Manual replacements