-
Notifications
You must be signed in to change notification settings - Fork 25
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
Feature/linters #68
Feature/linters #68
Conversation
Coverage reportTotal coverage
Report generated by 🧪jest coverage report action from af25d94 |
WalkthroughThe recent updates aim to enhance code quality and maintainability project-wide. The changes include adopting new ESLint plugins for improved code standards, transitioning to functional components using React hooks, and leveraging lodash for efficient object manipulation. These adjustments streamline development practices, reinforce immutability, and enhance code and test readability, collectively refining the project's structure for a more robust, maintainable codebase. Changes
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (10)
Files skipped from review due to trivial changes (1)
Files skipped from review as they are similar to previous changes (2)
Additional Context UsedGitHub Check Runs (1)
Additional comments not posted (7)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Review Status
Configuration used: CodeRabbit UI
Files ignored due to path filters (1)
yarn.lock
is excluded by!**/*.lock
Files selected for processing (39)
- .eslintrc.js (4 hunks)
- .gitignore (1 hunks)
- App.js (1 hunks)
- app.json (1 hunks)
- app/components/atoms/LanguageProvider/actions.js (1 hunks)
- app/components/atoms/LanguageProvider/index.js (2 hunks)
- app/components/atoms/LanguageProvider/reducer.js (1 hunks)
- app/components/atoms/LanguageProvider/tests/index.test.js (2 hunks)
- app/components/atoms/LanguageProvider/tests/reducer.test.js (1 hunks)
- app/components/molecules/CharacterWithQuote/index.js (1 hunks)
- app/components/molecules/If/index.js (1 hunks)
- app/components/molecules/If/tests/index.test.js (1 hunks)
- app/components/molecules/LogoWithInstructions/index.js (1 hunks)
- app/components/organisms/SimpsonsLoveWednesday/index.js (2 hunks)
- app/components/organisms/SimpsonsLoveWednesday/tests/index.test.js (1 hunks)
- app/i18n.js (2 hunks)
- app/rootSaga.js (1 hunks)
- app/scenes/ExampleScreen/index.js (2 hunks)
- app/scenes/ExampleScreen/reducer.js (1 hunks)
- app/scenes/ExampleScreen/saga.js (1 hunks)
- app/scenes/ExampleScreen/tests/index.test.js (2 hunks)
- app/scenes/ExampleScreen/tests/reducer.test.js (3 hunks)
- app/scenes/ExampleScreen/tests/selectors.test.js (1 hunks)
- app/scenes/RootScreen/index.js (2 hunks)
- app/scenes/RootScreen/reducer.js (1 hunks)
- app/scenes/RootScreen/saga.js (1 hunks)
- app/scenes/RootScreen/tests/index.test.js (1 hunks)
- app/scenes/RootScreen/tests/reducer.test.js (1 hunks)
- app/scenes/RootScreen/tests/saga.test.js (1 hunks)
- app/services/NavigationService.js (3 hunks)
- app/themes/fonts.test.js (1 hunks)
- app/utils/apiUtils.js (1 hunks)
- app/utils/createStore.js (1 hunks)
- app/utils/testUtils.js (2 hunks)
- babel.config.js (1 hunks)
- index.js (1 hunks)
- metro.config.js (1 hunks)
- package.json (1 hunks)
- setupTests.js (1 hunks)
Files skipped from review due to trivial changes (3)
- .gitignore
- app/scenes/ExampleScreen/tests/selectors.test.js
- app/scenes/RootScreen/saga.js
Additional Context Used
GitHub Check Runs (1)
Coverage annotations (🧪 jest-coverage-report-action) success (29)
app/components/atoms/LanguageProvider/actions.js: [warning] 10-13: 🧾 Statement is not covered
Warning! Not covered statement
app/components/atoms/LanguageProvider/actions.js: [warning] 9-9: 🕹 Function is not covered
Warning! Not covered function
app/scenes/ExampleScreen/index.js: [warning] 91-93: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/ExampleScreen/index.js: [warning] 92-92: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/ExampleScreen/index.js: [warning] 91-91: 🕹 Function is not covered
Warning! Not covered function
app/scenes/ExampleScreen/index.js: [warning] 92-92: 🕹 Function is not covered
Warning! Not covered function
app/scenes/RootScreen/index.js: [warning] 17-17: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/RootScreen/index.js: [warning] 33-35: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/RootScreen/index.js: [warning] 34-34: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/RootScreen/index.js: [warning] 16-16: 🕹 Function is not covered
Warning! Not covered function
app/scenes/RootScreen/index.js: [warning] 33-33: 🕹 Function is not covered
Warning! Not covered function
app/scenes/RootScreen/index.js: [warning] 34-34: 🕹 Function is not covered
Warning! Not covered function
app/services/NavigationService.js: [warning] 25-30: 🧾 Statement is not covered
Warning! Not covered statement
app/services/NavigationService.js: [warning] 43-48: 🧾 Statement is not covered
Warning! Not covered statement
app/services/NavigationService.js: [warning] 24-24: 🕹 Function is not covered
Warning! Not covered function
app/services/NavigationService.js: [warning] 42-42: 🕹 Function is not covered
Warning! Not covered function
app/utils/apiUtils.js: [warning] 17-17: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 18-18: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 38-38: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 38-38: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 11-11: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 16-18: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 29-31: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 37-39: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 38-38: 🕹 Function is not covered
Warning! Not covered function
app/scenes/ExampleScreen/index.js: [warning] 91-93: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/ExampleScreen/index.js: [warning] 92-92: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/ExampleScreen/index.js: [warning] 91-91: 🕹 Function is not covered
Warning! Not covered function
app/scenes/ExampleScreen/index.js: [warning] 92-92: 🕹 Function is not covered
Warning! Not covered function
app/scenes/RootScreen/index.js: [warning] 17-17: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/RootScreen/index.js: [warning] 33-35: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/RootScreen/index.js: [warning] 34-34: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/RootScreen/index.js: [warning] 16-16: 🕹 Function is not covered
Warning! Not covered function
app/scenes/RootScreen/index.js: [warning] 33-33: 🕹 Function is not covered
Warning! Not covered function
app/scenes/RootScreen/index.js: [warning] 34-34: 🕹 Function is not covered
Warning! Not covered function
Additional comments not posted (43)
metro.config.js (1)
1-3
: LGTM! Ensure that the metro configuration aligns with the project's requirements and that no additional configurations are needed.setupTests.js (1)
2-4
: LGTM! UsingLogBox.ignoreAllLogs()
is a good practice to keep the test environment clean by ignoring unnecessary log messages.index.js (1)
1-8
: LGTM! Ensure comprehensive test coverage for the entry point of the application to catch any potential issues early.app/components/atoms/LanguageProvider/actions.js (1)
3-7
: LGTM! Consider adding test coverage for thechangeLocale
function to ensure its functionality is correctly implemented and to catch any potential issues early.App.js (1)
15-15
: Consider refining the error handling strategy. Usingalert
can disrupt the user experience. It's better to handle errors in a way that informs the user without causing interruptions or to log the error for developers to investigate further.app/rootSaga.js (1)
5-9
: LGTM! Maintaining comprehensive documentation for complex functionalities like sagas is crucial for understandability and maintainability.app/components/molecules/If/index.js (1)
7-26
: LGTM! Proper type checking in React components is crucial for preventing runtime errors and ensuring component integrity.app/scenes/RootScreen/reducer.js (1)
18-22
: LGTM! Simplifying the logic flow and maintaining state immutability are important practices for ensuring the reducer's readability and reliability.app.json (1)
23-24
: LGTM! The addition ofbundleIdentifier
under theios
section inapp.json
is correctly implemented and consistent with the Android package name.app/components/atoms/LanguageProvider/tests/reducer.test.js (2)
6-6
: Refactoring the setup of mocked state into asetupMockedState
function enhances test clarity and reusability. Good practice!
17-17
: Using Immutable.js'sset
for state manipulation in tests is consistent with the reducer's state management approach. Well done!app/components/atoms/LanguageProvider/reducer.js (1)
25-29
: Refactoring the switch statement to use an object mapping for action types inlanguageProviderReducer
improves readability and maintainability. This is a modern and scalable approach. Well done!app/scenes/RootScreen/tests/index.test.js (1)
9-10
: IntroducingsetupJest
to extract common test setup logic is a best practice that enhances test clarity and reusability. Great job!app/utils/testUtils.js (1)
17-17
: Using lodash's_.get
for safer access totranslationMessages
inrenderWithIntl
enhances the robustness of the test utilities. Good improvement!app/scenes/ExampleScreen/saga.js (1)
26-30
: Adding a documentation comment forsearchListContainerSaga
enhances code readability and maintainability by clearly describing its purpose and behavior. Well done!app/scenes/RootScreen/tests/reducer.test.js (1)
9-9
: Refactoring the test setup into asetupTests
function enhances test clarity and reusability. This is a good practice for structuring tests.babel.config.js (3)
1-1
: Disable thefp/no-mutation
ESLint rule at the top of the file.
Consider if there's a way to adhere to functional programming principles instead of disabling the rule, as this could improve code quality and maintainability.
2-8
: Excellent addition of documentation comments for the Babel configuration function.
This enhances readability and maintainability by clearly explaining the purpose and usage of the function.
9-9
: The module export has been updated to an arrow function.
This change aligns with modern JavaScript practices and improves consistency across the codebase.app/components/molecules/If/tests/index.test.js (1)
35-37
: Updating theprops
for re-rendering theIf
component with a false condition is a good practice.
This ensures that the component behaves as expected under different conditions, enhancing the test's reliability.app/components/molecules/LogoWithInstructions/index.js (1)
32-37
: Adding a JSDoc comment for theLogoWithInstructions
function is an excellent practice.
It improves code documentation by specifying the props and return type, making the component easier to understand and use.app/components/atoms/LanguageProvider/tests/index.test.js (3)
9-9
: Adding an import forText
from 'react-native' is necessary for the test modifications.
This ensures that the test setup is correct and that the components can be properly rendered during testing.
12-16
: Modifying thechildren
element in the test to include<Text>Test</Text>
is a good update.
It makes the test more explicit about what it's rendering and testing, improving the clarity and reliability of the test.
25-25
: Refactoring the setup of Redux store in the test is a good practice.
It simplifies the test setup and makes it more modular, enhancing test maintainability.app/components/organisms/SimpsonsLoveWednesday/tests/index.test.js (1)
32-34
: Updating theprops.userErrorMessage
tonull
for re-rendering the component is a good practice.
This ensures that the component's behavior is tested under different conditions, enhancing the test's coverage and reliability.app/utils/createStore.js (2)
29-29
: Simplifying the comment related to connecting sagas to the redux store is a good practice.
It makes the comment more concise and focused, improving code readability.
31-32
: Changing the way middleware and enhancers are initialized and used in theexport default
function simplifies the setup.
This approach enhances code readability and maintainability by directly assigning values to arrays.app/i18n.js (2)
10-10
: Importing lodash to use for object manipulation in theformatTranslationMessages
function is a good practice.
It simplifies the code and improves readability and maintainability by leveraging a well-known utility library.
31-40
: Refactoring theformatTranslationMessages
function to use lodash for conditional message formatting is an excellent improvement.
It enhances the function's readability and maintainability by making the conditional logic clearer and more concise.app/scenes/ExampleScreen/reducer.js (1)
42-48
: Refactoring theexampleContainerReducer
to use an object mapping action types to corresponding functions simplifies the reducer's structure.
This approach replaces the traditional switch statement with a lookup mechanism, enhancing code readability and maintainability.app/components/molecules/CharacterWithQuote/index.js (1)
20-28
: LGTM! The added JSDoc comments enhance the readability and maintainability of the component by clearly documenting the props structure.app/scenes/ExampleScreen/tests/index.test.js (1)
10-10
: LGTM! The introduction of thesetupJest
function centralizes the setup forsubmitSpy
, enhancing test maintainability.app/scenes/RootScreen/tests/saga.test.js (1)
12-42
: LGTM! The refactoring of the test setup and modifications to navigation service calls enhance test readability and maintainability.app/components/organisms/SimpsonsLoveWednesday/index.js (1)
9-9
: LGTM! The renaming of the styled component toErr
is consistent and maintains readability.app/scenes/ExampleScreen/tests/reducer.test.js (1)
19-38
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [9-48]
LGTM! The use of variables for user data and error messages in tests enhances maintainability and readability.
app/components/atoms/LanguageProvider/index.js (1)
14-27
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [17-51]
LGTM! The documentation improvements and explicit typing of
dispatch
inmapDispatchToProps
enhance code readability and clarity.app/themes/fonts.test.js (2)
2-41
: LGTM! The use offontSizes
andfontWeights
objects withexpect.arrayContaining
andexpect.stringContaining
enhances test clarity and maintainability.
45-67
: LGTM! The refactored test assertions correctly utilize thefontSizes
andfontWeights
objects, improving test readability and maintainability.app/scenes/ExampleScreen/index.js (2)
47-71
: RefactoringExampleScreen
to a functional component and utilizing hooks aligns with modern React best practices, enhancing efficiency and readability.
51-53
: The use ofuseEffect
to handle component lifecycle events is correctly implemented, ensuring thatrequestFetchUser
is called when the component mounts..eslintrc.js (3)
9-27
: The addition of new ESLint plugins and extended configurations is a positive change, aiming to enforce stricter and more consistent coding standards across the project.
89-136
: The updated ESLint rules and the removal ofprettierOptions
reflect a commitment to maintaining a high standard of code quality. The inclusion of rules related to React, function complexity, imports, immutability, and React Native is commendable.
138-156
: The modifications to the settings for the import resolver, including the addition of aliases and paths, simplify imports and improve code readability, benefiting developers navigating the project.
app/utils/apiUtils.js
Outdated
export const getApiClient = (type = 'configApi') => _.get(apiClients, type); | ||
export const generateApiClient = (type = 'configApi') => { | ||
switch (type) { | ||
case 'configApi': | ||
apiClients[type] = createApiClientWithTransForm(Config.API_URL); | ||
return apiClients[type]; | ||
default: | ||
apiClients.default = createApiClientWithTransForm(Config.API_URL); | ||
const apiClientOption = { | ||
configApi: () => { | ||
_.set(apiClients, type, createApiClientWithTransForm(Config.API_URL)); | ||
return _.get(apiClients, type); | ||
}, | ||
default: () => { | ||
_.set( | ||
apiClients, | ||
'default', | ||
createApiClientWithTransForm(Config.API_URL) | ||
); | ||
return apiClients.default; | ||
} | ||
} | ||
}; | ||
if (_.get(apiClientOption, type)) return _.get(apiClientOption, type)(); | ||
return apiClientOption.default(); | ||
}; | ||
|
||
export const createApiClientWithTransForm = baseURL => { | ||
const api = create({ | ||
baseURL, | ||
headers: { 'Content-Type': 'application/json' } | ||
}); | ||
|
||
// eslint-disable-next-line complexity | ||
api.addResponseTransform(response => { | ||
const { ok, data } = response; | ||
if (ok && data) { | ||
response.data = mapKeysDeep(data, keys => camelCase(keys)); | ||
_.set( | ||
response, | ||
'data', | ||
mapKeysDeep(data, keys => camelCase(keys)) | ||
); | ||
} | ||
return response; | ||
}); | ||
|
||
api.addRequestTransform(request => { | ||
const { data } = request; | ||
if (data) { | ||
request.data = mapKeysDeep(data, keys => snakeCase(keys)); | ||
_.set( | ||
request, | ||
'data', | ||
mapKeysDeep(data, keys => snakeCase(keys)) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding tests to improve coverage for the modified functions and branches, ensuring that the new lodash-based logic works as expected.
app/services/NavigationService.js
Outdated
import { NavigationActions, StackActions } from '@react-navigation/compat'; | ||
import { _ } from 'lodash'; | ||
|
||
/** | ||
* The navigation is implemented as a service so that it can be used outside of components, for example in sagas. | ||
* | ||
* @see https://reactnavigation.org/docs/en/navigating-without-navigation-prop.html | ||
*/ | ||
|
||
let navigator; | ||
|
||
const navigatorObject = { | ||
navigator: null | ||
}; | ||
/** | ||
* This function is called when the RootScreen is created to set the navigator instance to use. | ||
*/ | ||
function setTopLevelNavigator(navigatorRef) { | ||
navigator = navigatorRef; | ||
} | ||
|
||
const setTopLevelNavigator = navigatorRef => { | ||
_.set(navigatorObject, 'navigator', navigatorRef); | ||
}; | ||
|
||
/** | ||
* Call this function when you want to navigate to a specific route. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [9-48]
Consider adding tests to improve coverage for the modified navigation functions, ensuring that the new logic works as expected.
app/scenes/RootScreen/index.js
Outdated
import React, { useEffect } from 'react'; | ||
|
||
export class RootScreen extends Component { | ||
componentDidMount() { | ||
// Run the startup saga when the application is starting | ||
this.props.startup(); | ||
} | ||
const RootScreen = props => { | ||
useEffect(() => { | ||
// Run the startup function when the component mounts | ||
props.startup(); | ||
}, []); | ||
|
||
setRefForTopLevelNavigtor = navigatorRef => { | ||
const setRefForTopLevelNavigtor = navigatorRef => { | ||
NavigationService.setTopLevelNavigator(navigatorRef); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Container testID="root-screen"> | ||
<AppNavigator /> | ||
</Container> | ||
); | ||
} | ||
} | ||
return ( | ||
<Container testID="root-screen"> | ||
<AppNavigator ref={setRefForTopLevelNavigtor} /> | ||
</Container> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactoring RootScreen
to a functional component and utilizing hooks aligns with modern React best practices. The implementation of useEffect
and conversion of methods to constants within the functional component are correctly done.
However, consider adding tests to improve coverage for the new functional component structure.
Would you like assistance in creating additional tests to cover the new changes?
app/scenes/ExampleScreen/index.js
Outdated
const requestFetchUser = () => () => { | ||
props.fetchUser(); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<Container> | ||
{this.props.userIsLoading ? ( | ||
<ActivityIndicator testID="loader" size="large" color="#0000ff" /> | ||
) : ( | ||
<View testID="example-container-content"> | ||
<SimpsonsLoveWednesday | ||
instructions={instructions} | ||
userErrorMessage={this.props.userErrorMessage} | ||
user={this.props.user} | ||
/> | ||
<CustomButtonParentView> | ||
<Button onPress={this.requestFetchUser()} title="Refresh" /> | ||
</CustomButtonParentView> | ||
</View> | ||
)} | ||
</Container> | ||
); | ||
} | ||
} | ||
useEffect(() => { | ||
requestFetchUser()(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider simplifying the requestFetchUser
method to directly call props.fetchUser
without returning a function. This will avoid confusion and potential bugs, especially since it's used as an onPress
handler.
- const requestFetchUser = () => () => {
+ const requestFetchUser = () => {
props.fetchUser();
};
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const requestFetchUser = () => () => { | |
props.fetchUser(); | |
}; | |
render() { | |
return ( | |
<Container> | |
{this.props.userIsLoading ? ( | |
<ActivityIndicator testID="loader" size="large" color="#0000ff" /> | |
) : ( | |
<View testID="example-container-content"> | |
<SimpsonsLoveWednesday | |
instructions={instructions} | |
userErrorMessage={this.props.userErrorMessage} | |
user={this.props.user} | |
/> | |
<CustomButtonParentView> | |
<Button onPress={this.requestFetchUser()} title="Refresh" /> | |
</CustomButtonParentView> | |
</View> | |
)} | |
</Container> | |
); | |
} | |
} | |
useEffect(() => { | |
requestFetchUser()(); | |
const requestFetchUser = () => { | |
props.fetchUser(); | |
}; | |
useEffect(() => { | |
requestFetchUser(); |
package.json
Outdated
"eslint-plugin-fp": "^2.3.0", | ||
"eslint-plugin-github": "^4.10.2", | ||
"eslint-plugin-immutable": "^1.0.0", | ||
"eslint-plugin-security": "^2.1.1", | ||
"eslint-plugin-sonarjs": "^0.24.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new ESLint plugins should be added to devDependencies
instead of dependencies
to avoid bloating the production build with development-only packages.
"dependencies": {
- "eslint-plugin-fp": "^2.3.0",
- "eslint-plugin-github": "^4.10.2",
- "eslint-plugin-immutable": "^1.0.0",
- "eslint-plugin-security": "^2.1.1",
- "eslint-plugin-sonarjs": "^0.24.0",
}
"devDependencies": {
+ "eslint-plugin-fp": "^2.3.0",
+ "eslint-plugin-github": "^4.10.2",
+ "eslint-plugin-immutable": "^1.0.0",
+ "eslint-plugin-security": "^2.1.1",
+ "eslint-plugin-sonarjs": "^0.24.0",
}
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
"eslint-plugin-fp": "^2.3.0", | |
"eslint-plugin-github": "^4.10.2", | |
"eslint-plugin-immutable": "^1.0.0", | |
"eslint-plugin-security": "^2.1.1", | |
"eslint-plugin-sonarjs": "^0.24.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- .eslintrc.js (3 hunks)
Additional comments not posted (4)
.eslintrc.js (4)
11-18
: Adding a wide range of ESLint plugins and extending configurations is a good practice for maintaining code quality. Ensure that all team members are aware of these changes and understand the new rules to maintain consistency in code submissions.
107-107
: Consider enabling thereact/no-array-index-key
rule to discourage the use of array indices as keys in React components, which can lead to performance issues and bugs in component state management.
110-120
: Therequire-jsdoc
rule is set to enforce JSDoc comments for function declarations. While this can improve code documentation, it may also add overhead for small or straightforward functions. Consider making this rule less strict or applying it selectively based on the project's documentation standards.
151-169
: The custom alias configuration in theimport/resolver
settings is a great way to simplify imports and improve code readability. Ensure that these aliases are well-documented and understood by all team members to avoid confusion.
.eslintrc.js
Outdated
plugins: [ | ||
'prettier', | ||
'github', | ||
'immutable', | ||
'sonarjs', | ||
'prettier', | ||
'redux-saga', | ||
'react-native', | ||
'react', | ||
'react-hooks', | ||
'jsx-a11y', | ||
'fp' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inclusion of multiple plugins, such as immutable
, sonarjs
, redux-saga
, and react-native
, enhances the project's linting capabilities. However, prettier
is listed twice (lines 21 and 25). Remove the duplicate entry to clean up the configuration.
plugins: [
'prettier',
'github',
'immutable',
'sonarjs',
- 'prettier',
'redux-saga',
'react-native',
'react',
'react-hooks',
'jsx-a11y',
'fp'
],
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
plugins: [ | |
'prettier', | |
'github', | |
'immutable', | |
'sonarjs', | |
'prettier', | |
'redux-saga', | |
'react-native', | |
'react', | |
'react-hooks', | |
'jsx-a11y', | |
'fp' | |
plugins: [ | |
'prettier', | |
'github', | |
'immutable', | |
'sonarjs', | |
'redux-saga', | |
'react-native', | |
'react', | |
'react-hooks', | |
'jsx-a11y', | |
'fp' |
.eslintrc.js
Outdated
} | ||
], | ||
'no-shadow': 'error', | ||
complexity: ['error', 2], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The complexity
rule is set with a threshold of 2, which is quite low and might be overly restrictive for most functions. Consider increasing this value to allow for more complex but manageable functions.
- complexity: ['error', 2],
+ complexity: ['error', 10],
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
complexity: ['error', 2], | |
complexity: ['error', 10], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 8
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (6)
- .eslintrc.js (3 hunks)
- app/i18n.js (2 hunks)
- app/scenes/RootScreen/tests/saga.test.js (1 hunks)
- app/services/NavigationService.js (3 hunks)
- app/utils/apiUtils.js (1 hunks)
- app/utils/testUtils.js (2 hunks)
Files skipped from review as they are similar to previous changes (3)
- app/i18n.js
- app/scenes/RootScreen/tests/saga.test.js
- app/utils/testUtils.js
Additional Context Used
GitHub Check Runs (1)
Coverage annotations (🧪 jest-coverage-report-action) success (29)
app/services/NavigationService.js: [warning] 25-30: 🧾 Statement is not covered
Warning! Not covered statement
app/services/NavigationService.js: [warning] 43-48: 🧾 Statement is not covered
Warning! Not covered statement
app/services/NavigationService.js: [warning] 24-24: 🕹 Function is not covered
Warning! Not covered function
app/services/NavigationService.js: [warning] 42-42: 🕹 Function is not covered
Warning! Not covered function
app/utils/apiUtils.js: [warning] 17-17: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 18-18: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 38-38: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 38-38: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 11-11: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 16-18: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 29-31: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 37-39: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 38-38: 🕹 Function is not covered
Warning! Not covered function
Additional comments not posted (11)
app/utils/apiUtils.js (4)
3-3
: Consider destructuringlodash
imports for better readability and potential tree-shaking benefits.
9-9
: EnsuregetApiClient
handles undefinedtype
values gracefully.
31-39
: Consider adding error handling for failed transformations inaddResponseTransform
.
47-51
: Verify thataddRequestTransform
correctly handles edge cases, such as non-objectdata
.app/services/NavigationService.js (4)
2-2
: Consider destructuringlodash
imports for better readability and potential tree-shaking benefits.
9-11
: EnsurenavigatorObject
is correctly initialized and used throughout the service.
27-27
: Verify thatnavigate
correctly handles undefinedrouteName
orparams
.
45-45
: EnsurenavigateAndReset
properly resets the navigation stack without unintended side effects..eslintrc.js (3)
11-19
: Ensure the extended ESLint configurations align with the project's coding standards.
122-122
: Consider adjusting thecomplexity
rule threshold to balance maintainability and flexibility.
150-168
: Verify theimport/resolver
settings to ensure they correctly resolve project paths and aliases.
app/utils/apiUtils.js
Outdated
const apiClientOption = { | ||
configApi: () => { | ||
set(apiClients, type, createApiClientWithTransForm(Config.API_URL)); | ||
return get(apiClients, type); | ||
}, | ||
default: () => { | ||
set(apiClients, 'default', createApiClientWithTransForm(Config.API_URL)); | ||
return apiClients.default; | ||
} | ||
} | ||
}; | ||
if (get(apiClientOption, type)) return get(apiClientOption, type)(); | ||
return apiClientOption.default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor generateApiClient
to simplify the handling of different types and improve readability.
- if (get(apiClientOption, type)) return get(apiClientOption, type)();
+ const clientGenerator = get(apiClientOption, type, apiClientOption.default);
+ return clientGenerator();
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const apiClientOption = { | |
configApi: () => { | |
set(apiClients, type, createApiClientWithTransForm(Config.API_URL)); | |
return get(apiClients, type); | |
}, | |
default: () => { | |
set(apiClients, 'default', createApiClientWithTransForm(Config.API_URL)); | |
return apiClients.default; | |
} | |
} | |
}; | |
if (get(apiClientOption, type)) return get(apiClientOption, type)(); | |
return apiClientOption.default(); | |
const apiClientOption = { | |
configApi: () => { | |
set(apiClients, type, createApiClientWithTransForm(Config.API_URL)); | |
return get(apiClients, type); | |
}, | |
default: () => { | |
set(apiClients, 'default', createApiClientWithTransForm(Config.API_URL)); | |
return apiClients.default; | |
} | |
}; | |
const clientGenerator = get(apiClientOption, type, apiClientOption.default); | |
return clientGenerator(); |
set(apiClients, 'default', createApiClientWithTransForm(Config.API_URL)); | ||
return apiClients.default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase test coverage for the default
case in generateApiClient
.
Would you like me to help with adding tests for this scenario?
set( | ||
response, | ||
'data', | ||
mapKeysDeep(data, keys => camelCase(keys)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve test coverage for the data transformation in addResponseTransform
.
I can assist in creating tests to ensure the transformation logic is correct.
*/ | ||
function navigate(routeName, params) { | ||
navigator.dispatch( | ||
navigatorObject.navigator.dispatch( | ||
NavigationActions.navigate({ | ||
routeName, | ||
params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase test coverage for the navigate
function to ensure it behaves as expected.
Would you like assistance in creating tests for this function?
*/ | ||
function navigateAndReset(routeName, params) { | ||
navigator.dispatch( | ||
navigatorObject.navigator.dispatch( | ||
StackActions.replace({ | ||
routeName, | ||
params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve test coverage for navigateAndReset
to verify navigation stack reset behavior.
I can help with adding tests for this functionality.
.eslintrc.js
Outdated
plugins: [ | ||
'github', | ||
'immutable', | ||
'sonarjs', | ||
'prettier', | ||
'redux-saga', | ||
'react-native', | ||
'react', | ||
'react-hooks', | ||
'jsx-a11y', | ||
'fp' | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove duplicate prettier
plugin entry to clean up the configuration.
plugins: [
'github',
'immutable',
'sonarjs',
- 'prettier',
'redux-saga',
'react-native',
'react',
'react-hooks',
'jsx-a11y',
'fp'
],
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
plugins: [ | |
'github', | |
'immutable', | |
'sonarjs', | |
'prettier', | |
'redux-saga', | |
'react-native', | |
'react', | |
'react-hooks', | |
'jsx-a11y', | |
'fp' | |
], | |
plugins: [ | |
'github', | |
'immutable', | |
'sonarjs', | |
'redux-saga', | |
'react-native', | |
'react', | |
'react-hooks', | |
'jsx-a11y', | |
'fp' | |
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (1)
- app/components/organisms/SimpsonsLoveWednesday/tests/index.test.js (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- app/components/organisms/SimpsonsLoveWednesday/tests/index.test.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Review Status
Configuration used: CodeRabbit UI
Files selected for processing (7)
- .eslintrc.js (3 hunks)
- app/components/molecules/CharacterWithQuote/index.js (1 hunks)
- app/scenes/ExampleScreen/index.js (2 hunks)
- app/scenes/ExampleScreen/tests/reducer.test.js (1 hunks)
- app/scenes/ExampleScreen/tests/selectors.test.js (1 hunks)
- app/scenes/RootScreen/reducer.js (2 hunks)
- app/utils/apiUtils.js (1 hunks)
Files skipped from review as they are similar to previous changes (4)
- app/components/molecules/CharacterWithQuote/index.js
- app/scenes/ExampleScreen/tests/reducer.test.js
- app/scenes/ExampleScreen/tests/selectors.test.js
- app/scenes/RootScreen/reducer.js
Additional Context Used
GitHub Check Runs (1)
Coverage annotations (🧪 jest-coverage-report-action) success (29)
app/scenes/ExampleScreen/index.js: [warning] 91-93: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/ExampleScreen/index.js: [warning] 92-92: 🧾 Statement is not covered
Warning! Not covered statement
app/scenes/ExampleScreen/index.js: [warning] 91-91: 🕹 Function is not covered
Warning! Not covered function
app/scenes/ExampleScreen/index.js: [warning] 92-92: 🕹 Function is not covered
Warning! Not covered function
app/utils/apiUtils.js: [warning] 17-17: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 18-18: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 38-38: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 38-38: 🧾 Statement is not covered
Warning! Not covered statement
app/utils/apiUtils.js: [warning] 11-11: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 16-18: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 29-31: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 37-39: 🌿 Branch is not covered
Warning! Not covered branch
app/utils/apiUtils.js: [warning] 38-38: 🕹 Function is not covered
Warning! Not covered function
Additional comments not posted (5)
app/utils/apiUtils.js (2)
9-22
: RefactorgenerateApiClient
to simplify the handling of different types and improve readability.This change aligns with the suggestion made in previous comments and enhances the code's readability and maintainability.
31-39
: Ensure proper test coverage for the data transformation inaddResponseTransform
.app/scenes/ExampleScreen/index.js (1)
47-72
: RefactorrequestFetchUser
to simplify its definition and usage.The change to define
requestFetchUser
within the functional component and the use ofuseEffect
for lifecycle events aligns with modern React best practices..eslintrc.js (2)
4-4
: Remove unusedprettierOptions
variable to avoid confusion.This change cleans up the configuration by removing unused variables.
97-172
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [11-147]
Ensure ESLint configuration aligns with project standards and best practices.
The inclusion of new ESLint plugins and rules enhances the project's linting capabilities, promoting better coding practices and standards.
app/utils/apiUtils.js
Outdated
@@ -1,41 +1,54 @@ | |||
import { create } from 'apisauce'; | |||
import mapKeysDeep from 'map-keys-deep'; | |||
import { camelCase, snakeCase } from 'lodash'; | |||
import { camelCase, snakeCase, set, get } from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider destructuring specific lodash functions to reduce bundle size.
- import { camelCase, snakeCase, set, get } from 'lodash';
+ import camelCase from 'lodash/camelCase';
+ import snakeCase from 'lodash/snakeCase';
+ import set from 'lodash/set';
+ import get from 'lodash/get';
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
import { camelCase, snakeCase, set, get } from 'lodash'; | |
import camelCase from 'lodash/camelCase'; | |
import snakeCase from 'lodash/snakeCase'; | |
import set from 'lodash/set'; | |
import get from 'lodash/get'; |
settings: { | ||
'import/resolver': { | ||
node: { | ||
app: './app', | ||
context: 'app', | ||
resolve: { | ||
alias: { | ||
'@assets': './app/assets', | ||
'@components': './app/components', | ||
'@containers': './app/containers', | ||
'@config': './app/config', | ||
'@navigators': './app/navigators', | ||
'@services': './app/services', | ||
'@themes': './app/themes', | ||
'@utils': './app/utils' | ||
}, | ||
"paths": ["app"], | ||
"modules": ["app", 'node_modules'], | ||
"extensions": ['.js', '.jsx', '.json', '.coffee', '.cjsx'], | ||
paths: ['app'], | ||
modules: ['app', 'node_modules'], | ||
extensions: ['.js', '.jsx', '.json', '.coffee', '.cjsx'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tip
Codebase Verification
Based on the script's output, it's evident that most of the directories mentioned in the alias settings of the .eslintrc.js
file exist within the project's structure, with the exception of app/containers
and the node_modules
directory. The absence of app/containers
suggests that either the project no longer uses this directory, or it was mistakenly included in the alias settings. The missing node_modules
directory could indicate that dependencies have not been installed yet, or the script was run in an environment where the node_modules
directory is not present or is located elsewhere.
Given this information, it's crucial to address the missing app/containers
directory in the alias settings if it's indeed no longer used or was included by mistake. Additionally, the situation with the node_modules
directory should be clarified, as its presence is fundamental for resolving node modules.
Analysis chain
Verify the import resolver settings for correctness and compatibility.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify the correctness of import resolver settings in ESLint configuration.
echo "Check if the import resolver settings align with the project's directory structure and module resolution."
Length of output: 223
Script:
#!/bin/bash
# Verify existence of directories mentioned in the alias settings.
directories=("app/assets" "app/components" "app/containers" "app/config" "app/navigators" "app/services" "app/themes" "app/utils" "app" "node_modules")
for dir in "${directories[@]}"; do
if [ -d "$dir" ]; then
echo "$dir exists."
else
echo "$dir does not exist."
fi
done
Length of output: 1249
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
const apiClientOption = { | ||
configApi: () => { | ||
set(apiClients, type, createApiClientWithTransForm(Config.API_URL)); | ||
return get(apiClients, type); | ||
}, | ||
default: () => { | ||
set(apiClients, 'default', createApiClientWithTransForm(Config.API_URL)); | ||
return apiClients.default; | ||
} | ||
} | ||
}; | ||
const clientGenerator = get(apiClientOption, type, apiClientOption.default); | ||
return clientGenerator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor generateApiClient
to simplify the handling of different types and improve readability.
- const clientGenerator = get(apiClientOption, type, apiClientOption.default);
+ const clientGenerator = apiClientOption[type] || apiClientOption.default;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const apiClientOption = { | |
configApi: () => { | |
set(apiClients, type, createApiClientWithTransForm(Config.API_URL)); | |
return get(apiClients, type); | |
}, | |
default: () => { | |
set(apiClients, 'default', createApiClientWithTransForm(Config.API_URL)); | |
return apiClients.default; | |
} | |
} | |
}; | |
const clientGenerator = get(apiClientOption, type, apiClientOption.default); | |
return clientGenerator(); | |
const apiClientOption = { | |
configApi: () => { | |
set(apiClients, type, createApiClientWithTransForm(Config.API_URL)); | |
return get(apiClients, type); | |
}, | |
default: () => { | |
set(apiClients, 'default', createApiClientWithTransForm(Config.API_URL)); | |
return apiClients.default; | |
} | |
}; | |
const clientGenerator = apiClientOption[type] || apiClientOption.default; | |
return clientGenerator(); |
// eslint-disable-next-line complexity | ||
api.addResponseTransform(response => { | ||
const { ok, data } = response; | ||
if (ok && data) { | ||
response.data = mapKeysDeep(data, keys => camelCase(keys)); | ||
set( | ||
response, | ||
'data', | ||
mapKeysDeep(data, keys => camelCase(keys)) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase test coverage for the data transformation in addResponseTransform
.
Would you like me to help with adding tests for this scenario?
set( | ||
request, | ||
'data', | ||
mapKeysDeep(data, keys => snakeCase(keys)) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure proper test coverage for the request data transformation to snake_case.
I can assist in creating tests to ensure the transformation logic is correct.
* @param params Route parameters. | ||
*/ | ||
function navigate(routeName, params) { | ||
navigator.dispatch( | ||
navigatorObject.navigator.dispatch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increase test coverage for the navigate
function to ensure it behaves as expected.
Would you like assistance in creating tests for this function?
* @param params Route parameters. | ||
*/ | ||
function navigateAndReset(routeName, params) { | ||
navigator.dispatch( | ||
navigatorObject.navigator.dispatch( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve test coverage for navigateAndReset
to verify navigation stack reset behavior.
I can help with adding tests for this functionality.
…vice_test Feat/notification service test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
const RootScreen = props => { | ||
useEffect(() => { | ||
// Run the startup function when the component mounts | ||
props.startup(); | ||
}, []); | ||
|
||
render() { | ||
return ( | ||
<Container testID="root-screen"> | ||
<AppNavigator /> | ||
</Container> | ||
); | ||
} | ||
} | ||
return ( | ||
<Container testID="root-screen"> | ||
<AppNavigator ref={setRefForTopLevelNavigtor} /> | ||
</Container> | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring of RootScreen
to a functional component using hooks is well-implemented. Consider improving test coverage for the new component structure to ensure all functionalities are correctly handled.
Would you like assistance in creating additional tests to cover the new changes?
const setTopLevelNavigator = navigatorRef => { | ||
set(navigatorObject, 'navigator', navigatorRef); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider simplifying the assignment of the navigator reference. Using lodash's set
function might be unnecessary for this straightforward assignment.
- set(navigatorObject, 'navigator', navigatorRef);
+ navigatorObject.navigator = navigatorRef;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
const setTopLevelNavigator = navigatorRef => { | |
set(navigatorObject, 'navigator', navigatorRef); | |
}; | |
const setTopLevelNavigator = navigatorRef => { | |
navigatorObject.navigator = navigatorRef; | |
}; |
Broekn this pr in small pr |
Ticket Link
Related Links
Description
Steps to Reproduce / Test
GIF's
Summary by CodeRabbit
CharacterWithQuote
component.ExampleScreen
to a functional component with hooks for fetching user data.formatTranslationMessages
function ini18n.js
for better readability and maintainability.RootScreen
andExampleScreen
for improved code quality.NavigationService
to use a more robust object handling method.