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 - echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
before_script: 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 - git clone https://github.com/oceanprotocol/barge
- cd barge - cd barge
- bash -x start_ocean.sh --no-pleuston 2>&1 > start_ocean.log & - bash -x start_ocean.sh --no-pleuston 2>&1 > start_ocean.log &
@ -53,6 +56,13 @@ script:
- npm run test:e2e || travis_terminate 1 - npm run test:e2e || travis_terminate 1
- ./scripts/build.sh - ./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: notifications:
email: false 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) [![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/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) [![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) [![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) [![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) [![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 }, { list?: boolean; recent?: number },
{ results: any[]; isLoading: boolean } { results: any[]; isLoading: boolean }
> { > {
public static contextType = User
public state = { results: [], isLoading: true } public state = { results: [], isLoading: true }
public _isMounted = false public _isMounted = false
@ -58,51 +60,46 @@ export default class AssetsUser extends PureComponent<
public render() { public render() {
const { account } = this.context const { account } = this.context
const { recent, list } = this.props
const { isLoading, results } = this.state
if (!account) return null
return ( return (
account && ( <div className={styles.assetsUser}>
<div className={styles.assetsUser}> {this.props.recent && (
{this.props.recent && ( <h2 className={styles.subTitle}>
<h2 className={styles.subTitle}> Your Latest Published Data Sets
Your Latest Published Data Sets </h2>
</h2> )}
)}
{this.state.isLoading ? ( {isLoading ? (
<Spinner /> <Spinner />
) : this.state.results.length ? ( ) : results.length ? (
<> <>
{this.state.results {results
.slice( .slice(0, recent || undefined)
0, .filter(asset => !!asset)
this.props.recent .map((asset: any) => (
? this.props.recent <AssetTeaser
: undefined list={list}
) key={asset.id}
.filter(asset => !!asset) asset={asset}
.map((asset: any) => ( />
<AssetTeaser ))}
list={this.props.list} {recent && (
key={asset.id} <Link className={styles.link} to="/history">
asset={asset} All Data Sets
/> </Link>
))} )}
{this.props.recent && ( </>
<Link className={styles.link} to="/history"> ) : (
All Data Sets <div className={styles.empty}>
</Link> <p>No Data Sets Yet.</p>
)} <Link to="/publish">+ Publish A Data Set</Link>
</> </div>
) : ( )}
<div className={styles.empty}> </div>
<p>No Data Sets Yet.</p>
<Link to="/publish">+ Publish A Data Set</Link>
</div>
)}
</div>
)
) )
} }
} }
AssetsUser.contextType = User

View File

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