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

Refactor: Rename Constants to Follow CamelCase Naming Convention #6126

Merged
merged 21 commits into from
Jan 18, 2025

Conversation

Akshaykomar890
Copy link
Contributor

Updated all constant variable names to follow the camelCase naming convention, removing underscores in the middle or end.

Ensured variable names remain descriptive and align with code readability best practices.

Akshaykomar890 and others added 10 commits January 6, 2025 00:53
>This PR refactors constant names in the project to adhere to Kotlin's UPPERCASE_SNAKE_CASE naming convention, improving code readability and maintaining consistency across the codebase.

>Renamed the following constants in LoginActivity:
>saveProgressDialog → SAVE_PROGRESS_DIALOG
>saveErrorMessage → SAVE_ERROR_MESSAGE
>saveUsername → SAVE_USERNAME
>savePassword → SAVE_PASSWORD

>Updated all references to these constants throughout the project.
Renamed variables to use camel case:
-UPLOAD_COUNT_THRESHOLD → uploadCountThreshold
-REVERT_PERCENTAGE_FOR_MESSAGE → revertPercentageForMessage
-REVERT_SHARED_PREFERENCE → revertSharedPreference
-UPLOAD_SHARED_PREFERENCE → uploadSharedPreference

Renamed variables with uppercase initials to lowercase for alignment with Kotlin conventions:
-Latitude → latitude
-Longitude → longitude
-Accuracy → accuracy

Refactored the following variable names:
-NUMBER_OF_QUESTIONS → numberOfQuestions
-MULTIPLIER_TO_GET_PERCENTAGE → multiplierToGetPercentage
This PR refactors the dialog setup code in CustomSelectorActivity to improve safety and readability by replacing explicit casts with null-safe generic calls for findViewById.

>Replaced explicit casting (as Button and as TextView) with the generic findViewById<T>() method for improved type safety.
>Added null-safety (?.) to avoid potential crashes if a view is not found in the dialog layout.

why changed:-
>Prevents runtime crashes caused by NullPointerException when a view is missing in the layout.
… findViewById

>PR refactors the unit test for NearbyParentFragment by replacing unsafe casting in the findViewById mocking statements with type-safe

>Ensured all findViewById mocks now use a consistent, type-safe format (findViewById<View>(...)) to reduce verbosity and potential casting errors.

>Verified the functionality of prepareViewsForSheetPosition remains unchanged, ensuring no regression in test behavior.
>Updated all constant variable names to follow the camelCase naming convention, removing underscores in the middle or end.

>Ensured variable names remain descriptive and align with code readability best practices.
@Akshaykomar890
Copy link
Contributor Author

@nicolas-raoul sir I have updated the "private val" to use "const val". I have also tested these changes using a unit test with the QuizControllerTest class, which ensures that the QuizController initialization and quiz retrieval functions work as expected. Please review the changes. 😊

nicolas-raoul

This comment was marked as duplicate.

@nicolas-raoul
Copy link
Member

Ah sorry GitHub was not showing me the latest comments somehow. Thanks! 🙂

@Akshaykomar890
Copy link
Contributor Author

@nicolas-raoul Sir I fixed 0c8763b and d4de3cd

@Akshaykomar890
Copy link
Contributor Author

Ah sorry GitHub was not showing me the latest comments somehow. Thanks! 🙂

😅No problem sir

@Akshaykomar890
Copy link
Contributor Author

@nicolas-raoul Could you please review my commit 7d6a460 and let me know if further adjustments are needed?

@@ -23,7 +23,7 @@ abstract class SwipableCardView @JvmOverloads constructor(

private var x1 = 0f
private var x2 = 0f
private val MINIMUM_THRESHOLD_FOR_SWIPE = 100f
private val minimumThresholdForSwipe = 100f
Copy link
Member

Choose a reason for hiding this comment

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

This one also should be const val, as it will not change at runtime.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@nicolas-raoul nicolas-raoul merged commit d4ababc into commons-app:main Jan 18, 2025
1 check passed
@Akshaykomar890
Copy link
Contributor Author

Looks good, thanks!

Thank you @nicolas-raoul 🤝

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.

3 participants