OasisDEX/oasis-react

View on GitHub

Showing 60 of 126 total issues

Function setActiveTradingPairEpic has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const setActiveTradingPairEpic = (args, sync = true) => (
  dispatch,
  getState
) => {
  const previousActiveTradingPair = tokens.activeTradingPair(getState());
Severity: Minor
Found in src/store/reducers/tokens.js - About 55 mins 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 subscribeLatestBlockFilterEpic has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

export const subscribeLatestBlockFilterEpic = () => async (
  dispatch,
  getState
) => {
  dispatch(subscribeLatestBlockFilter.pending());
Severity: Minor
Found in src/store/reducers/network/subscribeLatestBlockFilterEpic.js - About 45 mins 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 redirect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  redirect() {
    const params = this.props.match.params;
    const { baseToken, quoteToken } = this.props.defaultTradingPair.toJSON();

    if (!validateTradingPair(params.baseToken, params.quoteToken, generateTradingPairs(BASE_TOKENS, QUOTE_TOKENS))) {
Severity: Minor
Found in src/containers/OasisTrade.jsx - About 45 mins 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

Consider simplifying this complex logical expression.
Open

    if (
      isVolumeOrPriceEmptyOrZero(offerMakeType) ||
      !hasSufficientTokenAmount(offerMakeType) ||
      // !canSendTransaction ||
      !isBuyEnabled ||
Severity: Major
Found in src/store/selectors/offerMakes.js - About 40 mins to fix

Function setWrapMax has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const setWrapMax = () => (dispatch, getState) => {
  const activeUnwrappedToken = wrapUnwrap.activeUnwrappedToken(getState());
  const maxWrapValueInEther =
    activeUnwrappedToken === TOKEN_ETHER
      ? web3.fromWei(balances.ethBalance(getState()))
Severity: Minor
Found in src/store/reducers/wrapUnwrap.js - About 35 mins 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 setMaxButton has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  setMaxButton() {

    if (false === this.state.showMaxButton) {
      return null;
    }
Severity: Minor
Found in src/components/OfferTakeForm.jsx - About 35 mins 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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export const onNetworkCheckEndEpic = (
  dispatch,
  getState,
  setInitialSubscriptions,
  accountChanged
Severity: Minor
Found in src/store/reducers/network/onNetworkCheckEndEpic.js - About 35 mins 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 tokenBalanceMemo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  s => memoize((tokenName, balanceUnit = ETH_UNIT_ETHER, toBigNumber = true) => {
    const tokenBalance = s.get(tokenName);
    if (tokenBalance) {
      if (toBigNumber) {
        return web3.fromWei(new BigNumber(s.get(tokenName), 10), balanceUnit);
Severity: Minor
Found in src/store/selectors/balances.js - About 35 mins 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 transformRow has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  transformRow(row) {
    const { marketData = List(), initialMarketHistoryLoaded } = this.props;
    const [baseToken, quoteToken] = [row.get("base"), row.get("quote")];

    const pair = (
Severity: Minor
Found in src/components/OasisMarketWidget.js - About 35 mins 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 activeWrappedTokenBalance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  (wub, activeWrappedToken, asBN = true) => {
    if (!activeWrappedToken) {
      return null;
    } else if (wub) {
      const balances = wub.find(
Severity: Minor
Found in src/store/selectors/wrapUnwrap.js - About 35 mins 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 render has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const { order, baseCurrency, type, userToTradeBaseRelation, userToTradeAdditionalRelation } = this.props;
    const tradeTypeEnum =
      type || tradeType(order, baseCurrency, userToTradeBaseRelation, userToTradeAdditionalRelation);

Severity: Minor
Found in src/components/OasisTradeType.jsx - About 35 mins 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 asToken has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function asToken(addressOrToken, defaultToken) {
  const allTokens = Dapple.getTokens();

  if (!defaultToken
    || typeof defaultToken !== 'string'
Severity: Minor
Found in src/utils/functions.js - About 35 mins 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

Avoid too many return statements within this function.
Open

      return 0;
Severity: Major
Found in src/store/selectors/offerMakes.js - About 30 mins to fix

Avoid too many return statements within this function.
Open

    return (
      <div className={classes({ isAppLoading, globalFormLock })}>
        <BrowserRouter>{this.mainContent()}</BrowserRouter>
        <div>{OasisAppWrapper.versionInfo()}</div>
      </div>
Severity: Major
Found in src/containers/OasisApp.jsx - About 30 mins to fix

Function isOfferBelowLimit has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  (tokenMinSellLimitInWeiByOfferType, currentFormValues) => memoize(offerMakeType => {
    const { total, volume } = currentFormValues(offerMakeToFormName(offerMakeType));
    const tokenMinSellLimitInWei = tokenMinSellLimitInWeiByOfferType(offerMakeType);
    if (tokenMinSellLimitInWei === null) {
      return null;
Severity: Minor
Found in src/store/selectors/offerMakes.js - About 25 mins 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 removeOutliersFromArray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export function removeOutliersFromArray(data, fieldName, deviation) {
  const l = data.length;
  if (data.length <= 2) {
    return data;
  }
Severity: Minor
Found in src/utils/functions.js - About 25 mins 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 isVolumeGreaterThanOfferMax has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  (volume, offerData, offerTakeType) => {
    if (!offerData) {
      return false;
    }
    const buyHowMuch = web3.fromWei(offerData.get("buyHowMuch"));
Severity: Minor
Found in src/store/selectors/offerTakes.js - About 25 mins 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 LoadProgressSection has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const LoadProgressSection = ({
  loadedOffersList,
  offersTotalCount,
  showPercent
}) => {
Severity: Minor
Found in src/components/OasisLoadProgressSection.jsx - About 25 mins 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 loadTokenTransfersHistoryEpic has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const loadTokenTransfersHistoryEpic = (tokenName, address, config) => async (
  dispatch,
  getState
) => {
  const defaultAccount = accounts.defaultAccount(getState());
Severity: Minor
Found in src/store/reducers/transferHistory.js - About 25 mins 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 activeUnwrappedTokenBalance has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  (wub, activeUnwrappedToken, asBN = true) => {
    if (!activeUnwrappedToken) {
      return null;
    } else {
      const balance = wub
Severity: Minor
Found in src/store/selectors/wrapUnwrap.js - About 25 mins 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

Severity
Category
Status
Source
Language