diff --git a/source/engine/generateQuestions.js b/source/engine/generateQuestions.js index cf0113b21..07eda0374 100644 --- a/source/engine/generateQuestions.js +++ b/source/engine/generateQuestions.js @@ -75,8 +75,10 @@ let buildVariantTree = (allRules, path) => { } let buildPossibleInversion = (rule, flatRules, targetNames) => { - let inversions = R.path(['formule', 'inversion', 'avec'])(rule), - inversionObjects = inversions.map(i => + let ruleInversions = R.path(['formule', 'inversion', 'avec'])(rule) + if (!ruleInversions) return null + let + inversionObjects = ruleInversions.map(i => findRuleByDottedName( flatRules, disambiguateRuleReference(flatRules, rule, i) @@ -84,13 +86,11 @@ let buildPossibleInversion = (rule, flatRules, targetNames) => { ), yo = R.reject(({ name }) => targetNames.includes(name))([rule].concat(inversionObjects)) - return ( - inversions && { - inversions: yo, - question: rule.formule.inversion.question, - title: rule.formule.inversion.titre - } - ) + return { + inversions: yo, + question: rule.formule.inversion.question, + title: rule.formule.inversion.titre + } } export let makeQuestion = (flatRules, targetNames) => dottedName => {