combineReducer 中使用的减速器的声纳代码气味 [英] sonar code smell for reducer used in combineReducer

查看:56
本文介绍了combineReducer 中使用的减速器的声纳代码气味的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 combineReducer 像这样组合减速器和减速器

I am using combineReducer to combine reducers and reducer like this

const todo = (state = {}, action) => {
  switch (action.type) {
    //...

    case 'TOGGLE_TODO':
      if (state.id !== action.id) {
        return state
      }

      return Object.assign({}, state, {
        completed: !state.completed
      })

    default:
      return state
  }
}

我的问题是,如果我像这样定义减速器,我会闻到声纳代码的味道

My problem is if i am defining reducer like that i am getting sonar code smell

Function parameters with default values should be last1

但是在这个序列中结合reducer pass参数只是如何处理这个?

but combine reducer pass argument in this sequence only how to work on this?

推荐答案

我们在我们的项目中确实遇到了同样的问题,并且声纳允许您在 Administration -> 中定义规则和文件的排除项.配置 ->分析范围.

we did have the same issue within our project, and sonar allows you to define exclusions for rules and files in Administration -> Congifuration -> Analysis Scope.

您会在其中找到一个名为 Ignore issues on Multiple Criteria 的部分,您可以在那里输入规则和文件模式"以从该规则中排除文件.

you will find there a section called Ignore issues on Multiple Criteria and there you can enter the rule and a "file pattern" to exclude files from this rule.

喜欢:

这篇关于combineReducer 中使用的减速器的声纳代码气味的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆