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

Feat/add sonar #84

Merged
merged 6 commits into from
Apr 15, 2024
Merged

Feat/add sonar #84

merged 6 commits into from
Apr 15, 2024

Conversation

alichherawalla
Copy link
Contributor

@alichherawalla alichherawalla commented Apr 15, 2024

Ticket Link


Related Links


Description


Steps to Reproduce / Test


GIF's


Summary by CodeRabbit

  • New Features

    • Introduced new build configurations and debugging tools for Android applications.
    • Added new permissions and configurations in Android manifest files.
    • Enhanced app theme with new styles and colors.
    • Updated splash screen design.
  • Bug Fixes

    • Corrected import paths and updated navigation service implementations.
  • Documentation

    • Updated .gitignore files to ignore more items.
  • Refactor

    • Converted local functions to exported ones in navigation service.
  • Tests

    • Adjusted test configurations and corrected import statements in test files.
  • Chores

    • Updated project settings and dependencies for better performance and stability.

Copy link

coderabbitai bot commented Apr 15, 2024

Warning

Rate Limit Exceeded

@alichherawalla has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 14 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between dd9d814 and 21153ad.

Walkthrough

This update enhances a React Native project for Android, focusing on improved build configurations, debugging tools, and code management. Key changes include the introduction of new build scripts, updating .gitignore files, and refining the app's Android-specific settings and permissions. The project now supports advanced features like the New Architecture, TurboModules, and Fabric Renderer, alongside better integration with tools like SonarQube and Flipper for quality assurance and debugging.

Changes

File Path Change Summary
.gitignore, android/.gitignore Updated to include more directories and files, improving cleanliness in version control.
android/app/BUCK, .../build.gradle, .../build_defs.bzl Introduced new build configurations for Android using Buck and Gradle.
android/app/src/... (multiple files in src) Updated Android manifests, Java classes, and JNI related files to support new architecture features.
android/gradle/..., android/settings.gradle Updated Gradle scripts and settings for better build management.
app/... (multiple files in scenes and services) Updated import statements and refactored navigation services.
index.js, metro.config.js, package.json Enhanced project entry setup and dependencies management.
jest.config.js, sonar-project.properties Added configurations for SonarQube and Jest reporting.

Poem

🐇 Oh hark! A change does come,
🌟 In lines of code, where functions hum.
Build anew, with tools so fine,
📱 Android apps, now more divine.
Debug, deploy, let errors flee,
🚀 From tiny screens, to you from me.


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

github-actions bot commented Apr 15, 2024

Coverage report

Total coverage

Status Category Percentage Covered / Total
🟢 Statements 93.17% 191/205
🟡 Branches 87.8% 36/41
🟡 Functions 89.74% 70/78
🟢 Lines 94.88% 389/410

Status of coverage: 🟢 - ok, 🟡 - slightly more than threshold, 🔴 - under the threshold

Report generated by 🧪jest coverage report action from 21153ad

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

Comment on lines +1 to +7
cmake_minimum_required(VERSION 3.13)

# Define the library name here.
project(reactnativetemplatews_appmodules)

# This file includes all the necessary to let you build your application with the New Architecture.
include(${REACT_ANDROID_DIR}/cmake-utils/ReactNative-application.cmake)
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Review Summary

The verification script aimed to check if the REACT_ANDROID_DIR environment variable is set and points to a valid directory. The output indicates that this environment variable is not set, which means the directory inclusion in the CMakeLists.txt file might not function as expected during the build process.

Actionable Directive

The REACT_ANDROID_DIR environment variable is crucial for the JNI build configuration in CMakeLists.txt. It appears that this environment variable is not set in your build environment, which could lead to build failures or unexpected behavior. Please ensure that REACT_ANDROID_DIR is correctly defined and points to the appropriate directory containing ReactNative-application.cmake.

Analysis chain

The JNI build configuration in CMakeLists.txt is correctly set up for the new React Native architecture. Ensure that the REACT_ANDROID_DIR environment variable is correctly defined in your build environment.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Check if REACT_ANDROID_DIR is set and points to a valid directory
echo "REACT_ANDROID_DIR is set to: $REACT_ANDROID_DIR"
[ -d "$REACT_ANDROID_DIR" ] && echo "Directory exists" || echo "Directory does not exist"

Length of output: 143

Comment on lines +39 to +47
@Override
protected synchronized void maybeLoadOtherSoLibraries() {
if (!sIsSoLibraryLoaded) {
// If you change the name of your application .so file in the Android.mk file,
// make sure you update the name here as well.
SoLoader.loadLibrary("reactnativetemplatews_appmodules");
sIsSoLibraryLoaded = true;
}
}
Copy link

Choose a reason for hiding this comment

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

Ensure thread safety when modifying sIsSoLibraryLoaded.

The method maybeLoadOtherSoLibraries modifies the static variable sIsSoLibraryLoaded within a synchronized block, which is good for thread safety. However, ensure that all other accesses to sIsSoLibraryLoaded throughout the application are also synchronized or handled in a thread-safe manner to avoid potential race conditions.

The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'

<item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
Copy link

Choose a reason for hiding this comment

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

Remove or replace the problematic drawable reference.

The drawable @drawable/abc_textfield_default_mtrl_alpha referenced in the item with android:state_pressed="false" and android:state_focused="false" is known to cause a NullPointerException. Consider removing this item or replacing the drawable reference with one that does not cause issues.

def create_aar_targets(aarfiles):
for aarfile in aarfiles:
name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
lib_deps.append(":" + name)
Copy link

Choose a reason for hiding this comment

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

Ensure that lib_deps is defined before appending to it, as it could lead to runtime errors if not properly initialized.

def create_jar_targets(jarfiles):
for jarfile in jarfiles:
name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
lib_deps.append(":" + name)
Copy link

Choose a reason for hiding this comment

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

Ensure that lib_deps is defined before appending to it, as it could lead to runtime errors if not properly initialized.

@@ -25,17 +25,17 @@
);
});

it('should ensure that the navigation service is called after waiting for 1000ms', async () => {
it('should ensure that the navigation service is called after waiting for 1000ms11', async () => {
Copy link

Choose a reason for hiding this comment

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

There's a typo in the test description: "1000ms11" should be "1000ms".

- should ensure that the navigation service is called after waiting for 1000ms11
+ should ensure that the navigation service is called after waiting for 1000ms

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.

Suggested change
it('should ensure that the navigation service is called after waiting for 1000ms11', async () => {
it('should ensure that the navigation service is called after waiting for 1000ms', async () => {

@@ -21,13 +21,13 @@
* @param routeName The name of the route to navigate to. Routes are defined in RootScreen using createStackNavigator()
* @param params Route parameters.
*/
function navigate(routeName, params) {
export function navigate(routeName, params) {
Copy link

Choose a reason for hiding this comment

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

The functions navigate and navigateAndReset are now correctly exported, but they lack test coverage.

Would you like assistance in creating test cases for these functions?

Also applies to: 42-42

Comment on lines +23 to +68
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(
this,
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}

@Override
protected List<ReactPackage> getPackages() {
@SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
return packages;
}

@Override
protected String getJSMainModuleName() {
return "index";
}
});

private final ReactNativeHost mNewArchitectureNativeHost =
new ReactNativeHostWrapper(this, new MainApplicationReactNativeHost(this));

@Override
public ReactNativeHost getReactNativeHost() {
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
return mNewArchitectureNativeHost;
} else {
return mReactNativeHost;
}
}

@Override
public void onCreate() {
super.onCreate();
// If you opted-in for the New Architecture, we enable the TurboModule system
ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
SoLoader.init(this, /* native exopackage */ false);

initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);
}
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Review Summary

Subject: Verification of React Native Hosts Configuration and Flipper Initialization

The configuration of React Native hosts in both MainApplication.java and newarchitecture/MainApplicationReactNativeHost.java appears to be correctly implemented. Each class provides a tailored setup for handling React packages, JS modules, and developer support flags, which are crucial for the app's operation in different build configurations.

Regarding the initialization of Flipper, it is done in the onCreate() method of MainApplication.java. The context provided does not show a direct check against BuildConfig.DEBUG for initializing Flipper, which is typically expected to ensure that Flipper is only active in debug builds. This might be an area to consider revising for ensuring that Flipper is not included in production builds, depending on the project's configuration management.

Action Required:

  • It is recommended to ensure that Flipper initialization is wrapped with a debug condition check (BuildConfig.DEBUG) to prevent its inclusion in production builds.
Analysis chain

Review the configuration and initialization of React Native hosts and Flipper.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the React Native hosts are configured correctly and that Flipper is initialized only in debug mode.
rg --files-with-matches 'ReactNativeHost' android/app/src/main/java/com/wednesdaysolutions/rntws/
rg --files-with-matches 'initializeFlipper' android/app/src/main/java/com/wednesdaysolutions/rntws/

Length of output: 456



Script:

#!/bin/bash
# Check for the presence of BuildConfig.DEBUG in the condition for initializing Flipper
rg 'initializeFlipper\(this, getReactNativeHost\(\).getReactInstanceManager\(\)\);' android/app/src/main/java/com/wednesdaysolutions/rntws/MainApplication.java -C 5

# Verify the configuration of ReactNativeHost in newarchitecture/MainApplicationReactNativeHost.java
cat android/app/src/main/java/com/wednesdaysolutions/rntws/newarchitecture/MainApplicationReactNativeHost.java

Length of output: 5857

@alichherawalla alichherawalla force-pushed the feat/add-sonar branch 3 times, most recently from 265b67d to 5a934b1 Compare April 15, 2024 18:40
Copy link

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
93.66% (+0.49% 🔼)
192/205
🟢 Branches 87.8% 36/41
🟢 Functions
91.03% (+1.28% 🔼)
71/78
🟢 Lines
94.38% (+0.56% 🔼)
168/178
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / userService.js
100% 100% 100% 100%
🟡
... / navigationService.js
66.67% 100% 66.67% 66.67%
🟢
... / appNavigator.js
100% 100% 100% 100%

Test suite run success

48 tests passing in 20 suites.

Report generated by 🧪jest coverage report action from dd9d814

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

@@ -11,7 +11,7 @@
/**
* This function is called when the RootScreen is created to set the navigator instance to use.
*/
function setTopLevelNavigator(navigatorRef) {
export function setTopLevelNavigator(navigatorRef) {
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Review Summary

The review comment concerns the export of the setTopLevelNavigator function from the app/services/navigationService.js file and emphasizes the need for unit test coverage for this function.

Analysis of Shell Script Output

The output from the executed shell script intended to find test files covering setTopLevelNavigator shows results from app/scenes/RootScreen/tests/saga.test.js and mentions of the function in app/services/navigationService.js. However, the output does not clearly indicate that setTopLevelNavigator is directly tested or referenced within any test specifications (test or spec). The results from saga.test.js seem unrelated to direct testing of setTopLevelNavigator, as they involve different imports and functionality.

Conclusion

Given the output, there is no clear evidence of unit tests that directly cover the setTopLevelNavigator function. This aligns with the initial review comment's suggestion to ensure that this function is covered by unit tests.

Actionable Directive

Ensure Unit Test Coverage for setTopLevelNavigator

The verification process has revealed that there is no direct unit test coverage for the setTopLevelNavigator function in app/services/navigationService.js. It is recommended to implement specific unit tests to verify the functionality and robustness of this function, ensuring that it behaves as expected under various conditions.

Analysis chain

Export of setTopLevelNavigator. Ensure that this function is covered by unit tests.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for test files covering `setTopLevelNavigator`.
rg --type js "setTopLevelNavigator" --files-with-matches | xargs rg "test|spec"

Length of output: 588

Copy link

github-actions bot commented Apr 15, 2024

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 93.66% 192/205
🟢 Branches 87.8% 36/41
🟢 Functions 91.03% 71/78
🟢 Lines 94.38% 168/178

Test suite run success

48 tests passing in 20 suites.

Report generated by 🧪jest coverage report action from 21153ad

@alichherawalla alichherawalla force-pushed the feat/add-sonar branch 3 times, most recently from acab901 to a7610b8 Compare April 15, 2024 19:35

This comment has been minimized.

1 similar comment

This comment has been minimized.

@alichherawalla alichherawalla merged commit 83ada69 into master Apr 15, 2024
2 checks passed
Copy link

sonarqube-ws bot commented Apr 15, 2024

Passed

Analysis Details

0 Issues

  • Bug 0 Bugs
  • Vulnerability 0 Vulnerabilities
  • Code Smell 0 Code Smells

Coverage and Duplications

  • Coverage No coverage information (0.00% Estimated after merge)
  • Duplications No duplication information (0.00% Estimated after merge)

Project ID: wednesday-solutions_react-native-template_AY7hdnRSB2n8RRmGoU2M

View in SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant