React と Flux を使用して、フロントエンド Web アプリを開発しています。
したがって、次のように定数を定義します。
/js/constants/AppConstants.js
const KeyMirror = require('keymirror');
module.exports = {
PayloadSources: KeyMirror({
SERVER_ACTION: null,
VIEW_ACTION: null
})
};
/js/constants/ProductConstants.js
const KeyMirror = require('keymirror');
module.exports = {
ActionTypes: KeyMirror({
GET_PRODUCT: null,
UPDATE_PRODUCT: null,
})
};
これは完全に機能し、正しいので、これらのコードを Github にプッシュします (Codeclimate 統合を使用)。
Codeclimate は次のように述べています。
Similar code found in 1 other location (mass = 54)
const KeyMirror = require('keymirror');
明らかに、この行const KeyMirror = require('keymirror')
は 2 つの異なるファイルで定義されており、Codeclimate はこれを変更する必要があると考えています。しかし、これはライブラリをインポートするための単なるステートメントであると考えていました。
あなたはどのように思いますか?これをどのようにリファクタリングする必要がありますか?