Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code enhancement: applied sonarqube recommendations #3798

Merged
merged 4 commits into from
Oct 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be totally different, it used to be a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but it was immediately called with a useless argument, thus I removed one level of function call.

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