OasisDEX/oasis-react

View on GitHub

Showing 124 of 126 total issues

Similar blocks of code found in 13 locations. Consider refactoring.
Open

describe('(Container) OasisMyOrdersContainer', () => {
  const state = fromJS(global.storeMock);
  const initialProps = mapStateToProps(state);
  const initialActions = mapDispatchToProps(x => x);
  const props = {
Severity: Major
Found in src/containers/OasisMyOrdersContainer.test.js and 12 other locations - About 2 hrs to fix
src/containers/OasisAppLoadProgress.test.js on lines 13..38
src/containers/OasisEthBalanceWarningMessage.test.js on lines 13..38
src/containers/OasisGasPrice.test.js on lines 13..38
src/containers/OasisNotTheBestOfferPriceWarning.test.js on lines 13..38
src/containers/OasisTabsContainer.test.js on lines 13..38
src/containers/OasisTokenTransfer.test.js on lines 13..38
src/containers/OasisTradeOrders.test.js on lines 13..37
src/containers/OasisTransferMainWrapper.xtest.js on lines 13..37
src/containers/OasisWrapUnwrap.xtest.js on lines 12..36
src/containers/OasisWrapUnwrapBalances.test.js on lines 13..38
src/containers/OasisWrapUnwrapHistory.xtest.js on lines 13..39
src/containers/OasisYourNodeIsSyncing.test.js on lines 13..38

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 169.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 13 locations. Consider refactoring.
Open

describe('(Container) OasisNotTheBestOfferPriceWarning', () => {
  const state = fromJS(global.storeMock);
  const initialProps = mapStateToProps(state);
  const initialActions = mapDispatchToProps(x => x);
  const props = {
Severity: Major
Found in src/containers/OasisNotTheBestOfferPriceWarning.test.js and 12 other locations - About 2 hrs to fix
src/containers/OasisAppLoadProgress.test.js on lines 13..38
src/containers/OasisEthBalanceWarningMessage.test.js on lines 13..38
src/containers/OasisGasPrice.test.js on lines 13..38
src/containers/OasisMyOrdersContainer.test.js on lines 13..38
src/containers/OasisTabsContainer.test.js on lines 13..38
src/containers/OasisTokenTransfer.test.js on lines 13..38
src/containers/OasisTradeOrders.test.js on lines 13..37
src/containers/OasisTransferMainWrapper.xtest.js on lines 13..37
src/containers/OasisWrapUnwrap.xtest.js on lines 12..36
src/containers/OasisWrapUnwrapBalances.test.js on lines 13..38
src/containers/OasisWrapUnwrapHistory.xtest.js on lines 13..39
src/containers/OasisYourNodeIsSyncing.test.js on lines 13..38

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 169.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 13 locations. Consider refactoring.
Open

describe('(Container) OasisYourNodeIsSyncing', () => {
  const state = fromJS(global.storeMock);
  const initialProps = mapStateToProps(state);
  const initialActions = mapDispatchToProps(x => x);
  const props = {
Severity: Major
Found in src/containers/OasisYourNodeIsSyncing.test.js and 12 other locations - About 2 hrs to fix
src/containers/OasisAppLoadProgress.test.js on lines 13..38
src/containers/OasisEthBalanceWarningMessage.test.js on lines 13..38
src/containers/OasisGasPrice.test.js on lines 13..38
src/containers/OasisMyOrdersContainer.test.js on lines 13..38
src/containers/OasisNotTheBestOfferPriceWarning.test.js on lines 13..38
src/containers/OasisTabsContainer.test.js on lines 13..38
src/containers/OasisTokenTransfer.test.js on lines 13..38
src/containers/OasisTradeOrders.test.js on lines 13..37
src/containers/OasisTransferMainWrapper.xtest.js on lines 13..37
src/containers/OasisWrapUnwrap.xtest.js on lines 12..36
src/containers/OasisWrapUnwrapBalances.test.js on lines 13..38
src/containers/OasisWrapUnwrapHistory.xtest.js on lines 13..39

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 169.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function healthCheck has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

export const healthCheck = async (
  dispatch,
  getState,
  isInitialHealthcheck = false
) => {
Severity: Minor
Found in src/bootstrap/healthcheck.js - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Function onNetworkCheckEndEpic has 96 lines of code (exceeds 50 allowed). Consider refactoring.
Open

export const onNetworkCheckEndEpic = (
  dispatch,
  getState,
  setInitialSubscriptions,
  accountChanged
Severity: Major
Found in src/store/reducers/network/onNetworkCheckEndEpic.js - About 2 hrs to fix

OasisTakeOfferModalWrapper has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

export class OasisTakeOfferModalWrapper extends PureComponent {
  static takeOfferBtnLabel(offerTakeType, { buyToken, sellToken }) {
    switch (offerTakeType) {
      case TAKE_SELL_OFFER:
        return `Buy ${buyToken}`;
Severity: Minor
Found in src/containers/OasisTakeOfferModal.jsx - About 2 hrs to fix

Function render has 91 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  render() {
    const {
      handleSubmit,
      valid,
      makeTransfer,
Severity: Major
Found in src/containers/TokenTransferForm.jsx - About 2 hrs to fix

Function loadGNTWrapUnwrapsHistoryEpic has 88 lines of code (exceeds 50 allowed). Consider refactoring.
Open

const loadGNTWrapUnwrapsHistoryEpic = (address, config) => async (
  dispatch,
  getState
) => {
  const tokenName = TOKEN_GOLEM;
Severity: Major
Found in src/store/reducers/wrapUnwrapHistory.js - About 2 hrs to fix

SetTokenAllowanceTrustWrapper has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

export class SetTokenAllowanceTrustWrapper extends PureComponent {
  constructor(props) {
    super(props);
    this.state = {
      isToggleAllowanceTxPending: false
Severity: Minor
Found in src/containers/SetTokenAllowanceTrust.jsx - About 2 hrs to fix

Function render has 79 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  render() {
    const {
      valid,
      handleSubmit,
      initialized,
Severity: Major
Found in src/containers/OasisTokenUnwrapForm.jsx - About 2 hrs to fix

Function render has 78 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  render() {
    const {
      valid,
      handleSubmit,
      unwrappedToken,
Severity: Major
Found in src/containers/OasisTokenWrapForm.jsx - About 2 hrs to fix

Function loadEtherWrapUnwrapsHistoryEpic has 78 lines of code (exceeds 50 allowed). Consider refactoring.
Open

const loadEtherWrapUnwrapsHistoryEpic = (address, config) => async (
  dispatch,
  getState
) => {
  dispatch(loadWrapUnwrapsHistory$.pending());
Severity: Major
Found in src/store/reducers/wrapUnwrapHistory.js - About 2 hrs to fix

Function loadContact has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

function loadContact(abi, contractAddress, noProxy) {
  try {
    if (!web3.isAddress(contractAddress)) {
      throw new Error({
        msg: "contract address argument is not an valid ethereum address"
Severity: Minor
Found in src/utils/contracts/loadContract.js - About 2 hrs to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

File wrapUnwrap.js has 503 lines of code (exceeds 500 allowed). Consider refactoring.
Open

import { createAction, handleActions } from "redux-actions";
import { fromJS } from "immutable";
import { reset, formValueSelector, change } from "redux-form/immutable";

import {
Severity: Major
Found in src/store/reducers/wrapUnwrap.js - About 2 hrs to fix

Function render has 74 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  render() {
    const {
      offerTakeType,
      sellToken,
      buyToken,
Severity: Major
Found in src/containers/OasisTakeOfferModal.jsx - About 1 hr to fix

Function render has 73 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  render() {
    const { latestBlock: { number } = {} } = this.props;
    return (
      <section className={styles.LockedAccountSection}>
        <div>
Severity: Major
Found in src/components/OasisYourNodeIsSyncing.jsx - About 1 hr to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

describe('buyMaxEpic', () => {
  each([["max lower than offer", 13, 3, 12],
    ["max greater than offer", 1, 3, 12]])
    .test("%s", (description, balance, howMutch, price) => {
      const store = configureMockStore([thunk2Data(), thunk])({});
Severity: Major
Found in src/store/reducers/offerTakes.test.js and 1 other location - About 1 hr to fix
src/store/reducers/offerTakes.test.js on lines 64..80

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 148.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

describe('sellMaxEpic', () => {
  each([["balance greater than the offer", 13, 3, 12],
    ["balance lower than the offer", 1, 3, 12]])
    .test("%s", (description, balance, howMutch, price) => {
      const store = configureMockStore([thunk2Data(), thunk])({});
Severity: Major
Found in src/store/reducers/offerTakes.test.js and 1 other location - About 1 hr to fix
src/store/reducers/offerTakes.test.js on lines 46..62

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 148.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function render has 72 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  render() {
    return (
      <Line
        height={CHART_HEIGHT}
        data={{
Severity: Major
Found in src/components/OasisChartDepth.jsx - About 1 hr to fix

Function init has 65 lines of code (exceeds 50 allowed). Consider refactoring.
Open

const init = networkName => {
  const tokencontractsDeploymentAdressessList = config["tokens"][networkName];
  const marketDeploymentAddress = config["market"][networkName]["address"];

  const WETH = loadContact(
Severity: Major
Found in src/bootstrap/contracts.js - About 1 hr to fix
Severity
Category
Status
Source
Language