Skip to content

Commit

Permalink
BE-835 Fixed sonarcloud code smell issues (#193)
Browse files Browse the repository at this point in the history
Signed-off-by: jeeva <jeevasang@gmail.com>
  • Loading branch information
JeevaSang authored Oct 6, 2020
1 parent 34ab649 commit 72c0997
Show file tree
Hide file tree
Showing 16 changed files with 207 additions and 286 deletions.
6 changes: 3 additions & 3 deletions app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ const protocol = sslEnabled ? 'https' : 'http';
class Broadcaster extends WebSocket.Server {
/**
* Creates an instance of Broadcaster.
* @param {*} server
* @param {*} bServer
* @memberof Broadcaster
*/
constructor(server) {
constructor(bServer: any) {
super({
server
server: bServer
});
this.on('connection', function connection(ws, req) {
const location = url.parse(req.url, true);
Expand Down
8 changes: 4 additions & 4 deletions app/persistence/postgreSQL/PgService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
import { helper } from '../../common/helper';
import { Client } from 'pg';
import { Sequelize, Optional } from 'sequelize';
import { Sequelize } from 'sequelize';

const fs = require('fs');

Expand Down Expand Up @@ -417,12 +417,12 @@ export class PgService {
}

let updatewhereparm = ' (1=1) ';
const addSqlParams = [];
//const addSqlParams = [];

Object.keys(condition).forEach(k => {
const v = condition[k];
//const v = condition[k];

addSqlParams.push(v);
//addSqlParams.push(v);
updatewhereparm += ` and ${k}=? `;
});

Expand Down
2 changes: 1 addition & 1 deletion app/platform/fabric/rest/adminroutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ export async function adminroutes(router, platform) {
return await proxy.unregister(reqUser);
})
);
};
}
2 changes: 1 addition & 1 deletion app/rest/dbroutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,5 @@ export function dbroutes(router: any, platform: any) {
return requtil.invalidRequest(req, res);
}
});
}; // End dbroutes()
} // End dbroutes()

2 changes: 1 addition & 1 deletion app/rest/platformroutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ export async function platformroutes(router: { get: (arg0: string, arg1: { (req:
});
});
});
}; // End platformroutes()
} // End platformroutes()
8 changes: 4 additions & 4 deletions client/src/components/Header/HeaderView.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,10 @@ export class HeaderView extends Component {
}

componentDidMount() {
const { channels, currentChannel } = this.props;
const { channels: channelArr , currentChannel } = this.props;
const arr = [];
let selectedValue = {};
channels.forEach(element => {
channelArr.forEach(element => {
if (element.channel_genesis_hash === currentChannel) {
selectedValue = {
value: element.channel_genesis_hash,
Expand Down Expand Up @@ -468,7 +468,7 @@ export class HeaderView extends Component {
const {
isLoading,
selectedChannel,
channels,
channels: stateChannels,
notifyCount,
notifyDrawer,
adminDrawer,
Expand Down Expand Up @@ -533,7 +533,7 @@ export class HeaderView extends Component {
value={selectedChannel}
onChange={this.handleChange}
onFocus={this.reloadChannels.bind(this)}
options={channels}
options={stateChannels}
/>
</div>
{
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Lists/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export class Users extends Component {
this.setState({ userlists: newUsers });
}
async removeUser() {
const { unregister } = this.props;
await Promise.all([unregister({ user: this.state.selectedUser })]).then(
const { unregister: unregisterUser } = this.props;
await Promise.all([unregisterUser({ user: this.state.selectedUser })]).then(
message => {
if (message[0].status === 'success') {
this.reloadUsers();
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/View/LandingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class LandingPage extends Component {
getTransactionPerHour,
getTransactionPerMin,
updateLoadStatus,
userlist
userlist: userlistData
// getUserList
} = this.props;
await getChannel();
Expand All @@ -147,7 +147,7 @@ export class LandingPage extends Component {
getTransactionList(currentChannel),
getTransactionPerHour(currentChannel),
getTransactionPerMin(currentChannel),
userlist()
userlistData()
]);
clearTimeout(promiseTimeout);
updateLoadStatus();
Expand Down
4 changes: 2 additions & 2 deletions client/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const store = createStore({ theme: { mode } });

store.subscribe(themeSideEffect(store));

function themeSideEffect(store) {
function themeSideEffect(storeObj) {
let theme;
return () => {
const state = store.getState();
const state = storeObj.getState();
if (theme !== state.theme) {
theme = state.theme;
localStorage.setItem('theme-mode', theme.mode);
Expand Down
2 changes: 1 addition & 1 deletion client/src/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import React from 'react';
/* eslint-disable */
import Enzyme, { shallow, render, mount, configure } from 'enzyme';
import { shallow, render, mount, configure } from 'enzyme';
/* eslint-enable */
import sinon from 'sinon';
// import { configure } from 'enzyme';
Expand Down
4 changes: 2 additions & 2 deletions client/src/state/redux/auth/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import actions from '../charts/actions';

import Auth from '../../Auth';

const login = ({ user, password }, network) => dispatch =>
post('/auth/login', { user, password, network })
const login = ({ user, password }, networkObj) => dispatch =>
post('/auth/login', { user, password, network: networkObj })
.then(resp => {
Auth.authenticateUser(resp.token);
dispatch(errorAction(null));
Expand Down
34 changes: 10 additions & 24 deletions client/src/state/redux/auth/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,16 @@ const initialState = {
/* Reducers for Dashboard Charts */
const authReducer = (state = initialState, action) => {
switch (action.type) {
case types.LOGIN: {
return {
...state,
...action.payload
};
}
case types.ERROR: {
return {
...state,
...action.payload
};
}
case types.NETWORK: {
return {
...state,
...action.payload
};
}
case types.REGISTER: {
return {
...state,
...action.payload
};
}
case types.LOGIN:
case types.ERROR:
case types.NETWORK:
case types.REGISTER:
{
return {
...state,
...action.payload
};
}
case types.USERLIST: {
return {
...state,
Expand Down
40 changes: 20 additions & 20 deletions client/src/state/redux/charts/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import actions from './actions';
import { get } from '../../../services/request';

/* istanbul ignore next */
const blockPerHour = channel => dispatch =>
get(`/api/blocksByHour/${channel}/1`)
const blockPerHour = channelName => dispatch =>
get(`/api/blocksByHour/${channelName}/1`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -26,8 +26,8 @@ const blockPerHour = channel => dispatch =>
});

/* istanbul ignore next */
const blockPerMin = channel => dispatch =>
get(`/api/blocksByMinute/${channel}/1`)
const blockPerMin = channelName => dispatch =>
get(`/api/blocksByMinute/${channelName}/1`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -46,8 +46,8 @@ const blockPerMin = channel => dispatch =>
});

/* istanbul ignore next */
const changeChannel = channel => dispatch =>
get(`/api/changeChannel/${channel}`)
const changeChannel = channelName => dispatch =>
get(`/api/changeChannel/${channelName}`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand Down Expand Up @@ -106,8 +106,8 @@ const channelList = () => dispatch =>
});

/* istanbul ignore next */
const dashStats = channel => dispatch =>
get(`/api/status/${channel}`)
const dashStats = channelName => dispatch =>
get(`/api/status/${channelName}`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -126,8 +126,8 @@ const dashStats = channel => dispatch =>
});

/* istanbul ignore next */
const blockActivity = channel => dispatch =>
get(`/api/blockActivity/${channel}`)
const blockActivity = channelName => dispatch =>
get(`/api/blockActivity/${channelName}`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -146,14 +146,14 @@ const blockActivity = channel => dispatch =>
});

/* istanbul ignore next */
const notification = notification => dispatch => {
const notify = JSON.parse(notification);
const notification = notificationObj => dispatch => {
const notify = JSON.parse(notificationObj);
dispatch(actions.getNotification(notify));
};

/* istanbul ignore next */
const peerStatus = channel => dispatch =>
get(`/api/peersStatus/${channel}`)
const peerStatus = channelName => dispatch =>
get(`/api/peersStatus/${channelName}`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -172,8 +172,8 @@ const peerStatus = channel => dispatch =>
});

/* istanbul ignore next */
const transactionByOrg = channel => dispatch =>
get(`/api/txByOrg/${channel}`)
const transactionByOrg = channelName => dispatch =>
get(`/api/txByOrg/${channelName}`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -192,8 +192,8 @@ const transactionByOrg = channel => dispatch =>
});

/* istanbul ignore next */
const transactionPerHour = channel => dispatch =>
get(`/api/txByHour/${channel}/1`)
const transactionPerHour = channelName => dispatch =>
get(`/api/txByHour/${channelName}/1`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand All @@ -212,8 +212,8 @@ const transactionPerHour = channel => dispatch =>
});

/* istanbul ignore next */
const transactionPerMin = channel => dispatch =>
get(`/api/txByMinute/${channel}/1`)
const transactionPerMin = channelName => dispatch =>
get(`/api/txByMinute/${channelName}/1`)
.then(resp => {
if (resp.status === 500) {
dispatch(
Expand Down
Loading

0 comments on commit 72c0997

Please sign in to comment.