Skip to content

Commit

Permalink
BE-835 Fixed sonarcloud code smell issues (#191)
Browse files Browse the repository at this point in the history
Signed-off-by: jeeva <jeevasang@gmail.com>
  • Loading branch information
JeevaSang committed Oct 5, 2020
1 parent e164633 commit 907a93e
Show file tree
Hide file tree
Showing 19 changed files with 286 additions and 376 deletions.
2 changes: 1 addition & 1 deletion app/Explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export class Explorer {
const apirouter = Express.Router();

// Initializing the rest app services
await dbroutes(apirouter, platform);
dbroutes(apirouter, platform);
await platformroutes(apirouter, platform);
await adminroutes(apirouter, platform);

Expand Down
2 changes: 1 addition & 1 deletion app/common/ExplorerError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export function ExplorerError(...args: string[]) {
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.message = util.format(args);
};
}

//require('util').inherits(module.exports, Error);
2 changes: 1 addition & 1 deletion app/common/ExplorerMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ export enum explorerError {

// Fabric Message

};
}
63 changes: 22 additions & 41 deletions app/rest/dbroutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,7 @@ export function dbroutes(router: any, platform: any) {
to,
orgs
)
.then((rows: any) => {
if (rows) {
return res.send({ status: 200, rows });
}
});
.then(handleResult(req,res));
} else {
return requtil.invalidRequest(req, res);
}
Expand Down Expand Up @@ -229,7 +225,7 @@ export function dbroutes(router: any, platform: any) {
req.query.to
);
if (channel_genesis_hash && !isNaN(blockNum)) {
dbCrudService
return dbCrudService
.getBlockAndTxList(
req.network,
channel_genesis_hash,
Expand All @@ -238,13 +234,7 @@ export function dbroutes(router: any, platform: any) {
to,
orgs
)
.then((rows: any) => {
logger.debug('Return getBlockAndTxList ', rows);
if (rows) {
return res.send({ status: 200, rows });
}
return requtil.notFound(req, res);
});
.then(handleResult(req,res));
} else {
return requtil.invalidRequest(req, res);
}
Expand All @@ -267,14 +257,9 @@ export function dbroutes(router: any, platform: any) {
const hours = parseInt(req.params.hours);

if (channel_genesis_hash && !isNaN(hours)) {
dbStatusMetrics
return dbStatusMetrics
.getTxByMinute(req.network, channel_genesis_hash, hours)
.then((rows: any) => {
if (rows) {
return res.send({ status: 200, rows });
}
return requtil.notFound(req, res);
});
.then(handleResult(req,res));
} else {
return requtil.invalidRequest(req, res);
}
Expand All @@ -294,14 +279,9 @@ export function dbroutes(router: any, platform: any) {
const days = parseInt(req.params.days);

if (channel_genesis_hash && !isNaN(days)) {
dbStatusMetrics
return dbStatusMetrics
.getTxByHour(req.network, channel_genesis_hash, days)
.then((rows: any) => {
if (rows) {
return res.send({ status: 200, rows });
}
return requtil.notFound(req, res);
});
.then(handleResult(req,res));
} else {
return requtil.invalidRequest(req, res);
}
Expand All @@ -320,18 +300,24 @@ export function dbroutes(router: any, platform: any) {
const hours = parseInt(req.params.hours);

if (channel_genesis_hash && !isNaN(hours)) {
dbStatusMetrics
return dbStatusMetrics
.getBlocksByMinute(req.network, channel_genesis_hash, hours)
.then((rows: any) => {
if (rows) {
return res.send({ status: 200, rows });
}
return requtil.notFound(req, res);
});
.then(handleResult(req,res));
} else {
return requtil.invalidRequest(req, res);
}
});


function handleResult(req, res) {
return function (rows) {
if (rows) {
return res.send({ status: 200, rows });
}
return requtil.notFound(req, res);
};
}


/**
* *
Expand All @@ -346,14 +332,9 @@ export function dbroutes(router: any, platform: any) {
const days = parseInt(req.params.days);

if (channel_genesis_hash && !isNaN(days)) {
dbStatusMetrics
return dbStatusMetrics
.getBlocksByHour(req.network, channel_genesis_hash, days)
.then((rows: any) => {
if (rows) {
return res.send({ status: 200, rows });
}
return requtil.notFound(req, res);
});
.then(handleResult(req,res));
} else {
return requtil.invalidRequest(req, res);
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/FabricVersion.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0

// add new version of fabric here
const Version = ['v2.2', 'v1.4'];
const FabricVersion = ['v2.2', 'v1.4'];

export default Version;
export default FabricVersion;
31 changes: 31 additions & 0 deletions client/src/components/Container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { Component } from 'react';

import compose from 'recompose/compose';
import { withStyles } from '@material-ui/core/styles';

const styles = theme => ({
root: {
width: 'auto',
display: 'block', // Fix IE 11 issue.
marginLeft: theme.spacing.unit * 3,
marginRight: theme.spacing.unit * 3,
[theme.breakpoints.up(400 + theme.spacing.unit * 3 * 2)]: {
width: 400,
marginLeft: 'auto',
marginRight: 'auto'
}
}
});

export class Container extends Component {
render() {
const { classes, children } = this.props;
return (
<div className={classes.root}>
{children}
</div>
);
}
}

export default compose(withStyles(styles))(Container);
54 changes: 27 additions & 27 deletions client/src/components/Footer/FooterView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@
import React from 'react';
import { withStyles } from '@material-ui/core/styles';
import clientJson from '../../../package.json';
import Version from '../../FabricVersion';
import FabricVersion from '../../FabricVersion';

const styles = theme => {
const { type } = theme.palette;
const dark = type === 'dark';
return {
root: {
margin: '2%'
},
footer: {
backgroundColor: dark ? '#5e558e' : '#e8e8e8',
color: dark ? '#ffffff' : undefined,
textAlign: 'center',
position: 'fixed',
left: 0,
right: 0,
bottom: 0
}
};
const { type } = theme.palette;
const dark = type === 'dark';
return {
root: {
margin: '2%'
},
footer: {
backgroundColor: dark ? '#5e558e' : '#e8e8e8',
color: dark ? '#ffffff' : undefined,
textAlign: 'center',
position: 'fixed',
left: 0,
right: 0,
bottom: 0
}
};
};

const FooterView = ({ classes }) => (
<div className={classes.root}>
<div>
<div className={classes.footer}>
{'Hyperledger Explorer Client Version: '}
{clientJson.version}
&emsp;
{'Fabric Compatibility: '} {Version.map(v => v)}
</div>
</div>
</div>
<div className={classes.root}>
<div>
<div className={classes.footer}>
{'Hyperledger Explorer Client Version: '}
{clientJson.version}
&emsp;
{'Fabric Compatibility: '} {FabricVersion.map(v => v)}
</div>
</div>
</div>
);

export default withStyles(styles)(FooterView);
3 changes: 0 additions & 3 deletions client/src/components/Header/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { themeSelectors } from '../../state/redux/theme';
import UsersPanal from '../UsersPanal/UsersPanal';
import { authOperations } from '../../state/redux/auth';

import Register from '../Register';

// import Enroll from '../Enroll';

import {
Expand All @@ -48,7 +46,6 @@ import {
getTransactionPerMinType,
refreshType
} from '../types';
import getUserList from '../../state/redux/charts/actions';

const {
blockPerHour,
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Lists/Blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export class Blocks extends Component {
}}
minRows={0}
style={{ height: '750px' }}
showPagination={!(blockList.length < 5)}
showPagination={blockList.length >= 5}
/>

<Dialog
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Lists/Chaincodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class Chaincodes extends Component {
defaultPageSize={5}
filterable
minRows={0}
showPagination={!(chaincodeList.length < 5)}
showPagination={chaincodeList.length >= 5}
/>
<Dialog
open={dialogOpen}
Expand Down

0 comments on commit 907a93e

Please sign in to comment.