Skip to content

Commit

Permalink
Merge pull request #3798 from marmelab/code-enhancement-sonarqube-rec…
Browse files Browse the repository at this point in the history
…ommendations

Code enhancement: applied sonarqube recommendations
  • Loading branch information
fzaninotto authored Oct 11, 2019
2 parents c3334cd + 62a686a commit a887d3e
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 42 deletions.
22 changes: 6 additions & 16 deletions packages/ra-data-graphcool/src/buildVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const buildGetListVariables = introspectionResults => (

if (filterSome) {
const filter = Object.keys(params.filter[key]).reduce(
(acc, k) => ({
...acc,
(filter_acc, k) => ({
...filter_acc,
[`${k}_in`]: params.filter[key][k],
}),
{}
Expand Down Expand Up @@ -85,7 +85,7 @@ const buildGetListVariables = introspectionResults => (
};
};

const buildCreateUpdateVariables = () => (
const buildCreateUpdateVariables = (
resource,
aorFetchType,
params,
Expand Down Expand Up @@ -147,28 +147,18 @@ export default introspectionResults => (
};
}
case GET_ONE:
case DELETE:
return {
id: params.id,
};
case CREATE:
case UPDATE: {
return buildCreateUpdateVariables(introspectionResults)(
resource,
aorFetchType,
params,
queryType
);
}
case CREATE: {
return buildCreateUpdateVariables(introspectionResults)(
return buildCreateUpdateVariables(
resource,
aorFetchType,
params,
queryType
);
}
case DELETE:
return {
id: params.id,
};
}
};
24 changes: 7 additions & 17 deletions packages/ra-data-graphql-simple/src/buildVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const prepareParams = (params, queryType, introspectionResults) => {
return;
}

result[key] = castType(param, arg.type, introspectionResults.types);
result[key] = castType(param, arg.type);
});

return result;
Expand All @@ -115,8 +115,8 @@ const buildGetListVariables = introspectionResults => (

if (filterSome) {
const filter = Object.keys(params.filter[key]).reduce(
(acc, k) => ({
...acc,
(filter_acc, k) => ({
...filter_acc,
[`${k}_in`]: params.filter[key][k],
}),
{}
Expand Down Expand Up @@ -185,7 +185,7 @@ const buildGetListVariables = introspectionResults => (
};
};

const buildCreateUpdateVariables = () => (
const buildCreateUpdateVariables = (
resource,
aorFetchType,
params,
Expand Down Expand Up @@ -256,28 +256,18 @@ export default introspectionResults => (
};
}
case GET_ONE:
case DELETE:
return {
id: preparedParams.id,
};
case CREATE:
case UPDATE: {
return buildCreateUpdateVariables(introspectionResults)(
resource,
aorFetchType,
preparedParams,
queryType
);
}
case CREATE: {
return buildCreateUpdateVariables(introspectionResults)(
return buildCreateUpdateVariables(
resource,
aorFetchType,
preparedParams,
queryType
);
}
case DELETE:
return {
id: preparedParams.id,
};
}
};
2 changes: 1 addition & 1 deletion packages/ra-tree-core/src/getTreeFromArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ export default (data, parentSource) => {
id: 'id',
parentId: parentSource,
})
.map(node => createNode(node, 1))
.map(node => createNode(node))
.map(node => addParent(node, null));
};
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/form/SimpleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const SimpleForm = ({ initialValues, defaultValue, saving, ...props }) => {

const submit = values => {
const finalRedirect =
typeof redirect === undefined ? props.redirect : redirect.current;
typeof redirect.current === undefined
? props.redirect
: redirect.current;
const finalValues = sanitizeEmptyValues(finalInitialValues, values);

props.save(finalValues, finalRedirect);
Expand Down
4 changes: 3 additions & 1 deletion packages/ra-ui-materialui/src/form/TabbedForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const TabbedForm = ({ initialValues, defaultValue, saving, ...props }) => {

const submit = values => {
const finalRedirect =
typeof redirect === undefined ? props.redirect : redirect.current;
typeof redirect.current === undefined
? props.redirect
: redirect.current;
const finalValues = sanitizeEmptyValues(finalInitialValues, values);

props.save(finalValues, finalRedirect);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import InputHelperText from './InputHelperText';
import AutocompleteSuggestionList from './AutocompleteSuggestionList';
import AutocompleteSuggestionItem from './AutocompleteSuggestionItem';

interface Props {}

interface Options {
suggestionsContainerProps?: any;
labelProps?: any;
Expand Down Expand Up @@ -93,7 +91,7 @@ interface Options {
* <AutocompleteArrayInput source="author_id" options={{ fullWidthInput: true }} />
*/
const AutocompleteArrayInput: FunctionComponent<
Props & InputProps<TextFieldProps & Options> & DownshiftProps<any>
InputProps<TextFieldProps & Options> & DownshiftProps<any>
> = ({
allowEmpty,
classes: classesOverride,
Expand Down
4 changes: 1 addition & 3 deletions packages/ra-ui-materialui/src/input/AutocompleteInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import InputHelperText from './InputHelperText';
import AutocompleteSuggestionList from './AutocompleteSuggestionList';
import AutocompleteSuggestionItem from './AutocompleteSuggestionItem';

interface Props {}

interface Options {
suggestionsContainerProps?: any;
labelProps?: any;
Expand Down Expand Up @@ -93,7 +91,7 @@ interface Options {
* <AutocompleteInput source="author_id" options={{ fullWidthInput: true }} />
*/
const AutocompleteInput: FunctionComponent<
Props & InputProps<TextFieldProps & Options> & DownshiftProps<any>
InputProps<TextFieldProps & Options> & DownshiftProps<any>
> = ({
allowEmpty,
classes: classesOverride,
Expand Down

0 comments on commit a887d3e

Please sign in to comment.