Skip to content

Fix part of issue #8423 Lint concatenation checker #19908

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

Merged
merged 185 commits into from
Jun 10, 2024

Conversation

Helper2020
Copy link
Collaborator

@Helper2020 Helper2020 commented Mar 8, 2024

Overview

  1. This PR fixes or fixes part of Implement new linter checks #8423].
  2. This PR adds Add a lint check to prevent the usage of string concatenation and promote string interpolation.

Essential Checklist

  • The PR title starts with "Fix #bugnum: " or "Fix part of #bugnum: ...", followed by a short, clear summary of the changes.
  • I have followed the instructions for making a code change.
  • I have assigned the correct reviewers to this PR (or will leave a comment with the phrase "@{{reviewer_username}} PTAL" if I don't have permissions to assign reviewers directly).
  • The linter/Karma presubmit checks pass on my local machine, and my PR follows the coding style guide).
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)

@Helper2020 Helper2020 requested a review from a team as a code owner March 8, 2024 22:27
Copy link

oppiabot bot commented Mar 8, 2024

Hi @Helper2020, can you complete the following:

  1. The body of this PR is missing the overview section, please update it to include the overview.
  2. The body of this PR is missing the proof that changes are correct section, please update it to include the section.
    Thanks!

Copy link

oppiabot bot commented Mar 8, 2024

Assigning @vojtechjelinek for the first pass review of this PR. Thanks!

@Helper2020
Copy link
Collaborator Author

@seanlip PTAL, @U8NWXD PTAL

@oppiabot oppiabot bot assigned seanlip and U8NWXD and unassigned Helper2020 Mar 8, 2024
Copy link

oppiabot bot commented Mar 8, 2024

Unassigning @Helper2020 since a re-review was requested. @Helper2020, please make sure you have addressed all review comments. Thanks!

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Thanks @Helper2020! Could you please fix the lint checks that are failing on CI? Thanks.

@seanlip seanlip assigned Helper2020 and unassigned seanlip Mar 9, 2024
Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Left a few comments.

Comment on lines 2954 to 2956
if (isinstance(left_inferred.value, str) and
isinstance(right_inferred.value, str)):
self.add_message('prefer-string-interpolation', node=node)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (isinstance(left_inferred.value, str) and
isinstance(right_inferred.value, str)):
self.add_message('prefer-string-interpolation', node=node)
if (
isinstance(left_inferred.value, str) and
isinstance(right_inferred.value, str)
):
self.add_message('prefer-string-interpolation', node=node)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link

oppiabot bot commented Mar 10, 2024

Unassigning @vojtechjelinek since the review is done.

@U8NWXD
Copy link
Member

U8NWXD commented Mar 10, 2024

@Helper2020 please correct the issues flagged by Oppiabot in #19908 (comment):

Hi @Helper2020, can you complete the following:

  1. The body of this PR is missing the overview section, please update it to include the overview.
  2. The body of this PR is missing the proof that changes are correct section, please update it to include the section.
    Thanks!

I'm de-assigning myself for now until these issues and CI checks are fixed

@U8NWXD U8NWXD removed their assignment Mar 10, 2024
@Helper2020
Copy link
Collaborator Author

@vojtechjelinek I'm not sure how I can handle errors from .infer() without try-except blocks. Any suggestions?

@vojtechjelinek
Copy link
Contributor

@vojtechjelinek I'm not sure how I can handle errors from .infer() without try-except blocks. Any suggestions?

Why can't you use try-except?

@Helper2020
Copy link
Collaborator Author

@vojtechjelinek I'm not sure how I can handle errors from .infer() without try-except blocks. Any suggestions?

Why can't you use try-except?

I can, just according to the coding style guide, raising exceptions are rarely used.

Copy link
Collaborator Author

@Helper2020 Helper2020 left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@seanlip seanlip left a comment

Choose a reason for hiding this comment

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

Sorry for the late reply. LGTM for my codeowner files, thanks @Helper2020!

@seanlip
Copy link
Member

seanlip commented Jun 8, 2024

@Helper2020 Just a note, follow the syntax in the "essential checklist" if you want to assign reviewers, otherwise Oppiabot might not recognize it. I think the "PTAL" comes at the end not at the beginning.

Copy link
Contributor

@vojtechjelinek vojtechjelinek left a comment

Choose a reason for hiding this comment

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

Thanks! Just one nit.

Comment on lines +192 to +195
score_category = ('%s%s%s' % (
suggestion_models.SCORE_TYPE_CONTENT,
suggestion_models.SCORE_CATEGORY_DELIMITER, exploration.category
))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
score_category = ('%s%s%s' % (
suggestion_models.SCORE_TYPE_CONTENT,
suggestion_models.SCORE_CATEGORY_DELIMITER, exploration.category
))
score_category = ('%s%s%s' % (
suggestion_models.SCORE_TYPE_CONTENT,
suggestion_models.SCORE_CATEGORY_DELIMITER, exploration.category
))

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto below

Copy link

oppiabot bot commented Jun 9, 2024

Unassigning @vojtechjelinek since they have already approved the PR.

@U8NWXD U8NWXD added this pull request to the merge queue Jun 10, 2024
@oppiabot oppiabot bot unassigned U8NWXD Jun 10, 2024
Copy link

oppiabot bot commented Jun 10, 2024

Unassigning @U8NWXD since they have already approved the PR.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 10, 2024
@Helper2020
Copy link
Collaborator Author

@U8NWXD For some reason the bot removed the pr from the merge queue.

@seanlip seanlip added this pull request to the merge queue Jun 10, 2024
Merged via the queue into oppia:develop with commit 879127f Jun 10, 2024
81 checks passed
@Helper2020 Helper2020 deleted the lint-concatenation-checker branch June 10, 2024 18:57
AFZL210 pushed a commit to AFZL210/oppia that referenced this pull request Jun 12, 2024
* Added string concatentation class checker

* Added string concatenation checker tests

* Refactored String concatenation checker class

* Fixed linting issues

* Fixed symolic name conflict

* Fixed linting issues

* Fixing linting issues in pylint extenstions test file

* Fixed any type error

* Added try-except block and test case for inference errors

* Shorted message id name

* Added test case, one side str and other side is not

* Fixed linting issues

* Fixed linting issue email_services.py

* Fixed refactor message strings email_services.py

* removed string concactenations learner_group_test

* Fixed string concatenation issues in acl_decorators_test.py

* Fixed string concacention issue in cron_test.py

* implemented suggestions cron_test.py

* Implemented suggested changes in acl_decorators_test.py

* Removed string concatenations in favor of string intropolations in state_domain_test.py

* Replace string concatenations with string intropolation  from stats_domain_test.py

* Removed string concatenation in favor of string intropolation in general_purpose_linter.py

* Removed string concactenation app_feedback_report_domain_test.py

* Removed String concatenations from email_manager_test.py

* Removed string concatenation in test_utils.py

* Removed string concatenation in blog_domain_test.py

* Removed string concatenation from story_domain

* Removed string concantentations from tasks_test.py

* Removes string concantentions in admin.py

* Removed string concatentation from html.linter.py

* Removed string concatenation in gae_models_test

* Removed string concatenations from run_frontend_tests_test.py

* Removed string concatenations from suggestion_registry_test.py

* Removed string concatenation from feedback_domain_test

* Removed string concatenations from email_manager.py

* Removed string concatenations from story_node_jobs_test.py

* Removed string concatenations from resourse_test

* Removed string concatenation from exp_domain.py

* Removed string concatactenation from topic_editor.py

* Removed string concatenation js_ts_linter.py

* Removed string concantenation from blog_domin.py

* Removed string concatenation from utils_test.py

* Removed string concatenation from dev_mode_email_services_test.py

* Removed string concatenation from story_fetchers_test.py

* Removed string concatenation from start.py

* Removed string concatenation from contributor_dashboard_test.py

* Removed string concatenation from feature_flag_services_test

* Removed string concatenation from skill_domain_test

* Removed string concatenation from generators_test.py

* Removed string concatenation from dev_mode_email_services/py

* Removed string concatenation from story_services.py

* Fixed invalid data type error in test_util.py

* Removed string concatenation from user_services_test.py

* Removed string concatenation from question_domain.py

* Removed string concatenation from profile.py

* Removed string concatenations from exp_migration_jobs_test.py

* Removed string concatenations from common.py

* Minor refactor

* Removed string concatenations from collection_domain.py

* Removed string concatenations from profil_test.py

* Removed string concatenations from update_configs.py

* Removed string concatenation from acl_decorators.py

* Removed string concatenations from blog_services_test

* Removed string concatenation from platform_parameter_domain_test.py

* Removed string concatenation from admin_test.py

* Removed string concatenation from collection_services_test.py

* Removed string concatenations from stetup_test.py

* Removed string concatenations from check_overall_backend_test_coverage_test

* Removed string concatenations from skill_mastery_test.py

* Removed string concatenations email_services_test.py

* Removed string concatenations gae_models_test

* Removed string concatenation reader_test.py

* Removed string concatenations run_typescript_checks.py

* Removed string concatenations question_editor.py

* Removed string concatenation contributor_admin_stats_job_test.py

* Removed string concatenation base_test.py

* Removed string concatenation gae_app_identity_services.py

* Removed string concatenations takeout_service_test.py

* Removed string concatenation story_domain_test.py

* Removed string concatenation objects.py

* Removed string concatenation topic_editor_test.py

* Removed string concatenation story_services_test

* Removed string concatenation run_frontend_tests.py

* Removed string concatenations js_ts_linter_test.py

* Added feature to string concanation linter to ignore datetime object

* Fixed linting errors in pylint_extensions.py

* Removed string concatenations feedback_services_test.py

* Removed string concatenations linter_utils_test.py

* Fixed linting errors in pylint_extensions_test.py

* Removed string concatenations topics_and_skills_dashboard

* Removed string concatenations suggestions_services_test/py

* Removed string concatenations exp_services_test.py

* Removed string concatenation from TextInput.py

* Removed string concatenations from suggestion_services.py

* Removed string concatenation gae_models.py

* Fixed linting errors in gae_models.y

* Removed string concatenation from summary_services_test.py

* Implented suggested changes in pylint_extensions_test.py

* Removed string concatenation from story_fetchers_test

* Removed string concatenations suggestion_services_test.py

* Removed white space from suggestion_services_test.py

* Updated lint-concatenation  message id and next message id value

* Removed string concatenations from suggestion_test.py

* Removed string concatenation suggestion_edit_state_contented_deletion_jobs.py

* Removed string concatenation from common.py

* Removed string concatenation user_validation_jobs_test.py

* Removed string concatenation skill_mastery_test

* Removed string concatenation reader_test/py

* Removed string concatenations suggestion_edit_state_content_jobs_test.py

* Fixed spacing in acl_decorators_test.py

* Rephrased String concantenation checker message

* Changed test function names in PreventStringConcatenationCheckerTests

* deindent 4 spaces to match scope'

* Indented by 4 to match scope

* Refactor code

* Implemented suggestions

* Implemented suggested changes

* Refactor line of code in js_ts_linter.py

* Removed redudant occurances of the word of

* Fixed string interpolation error

* Refactored pylint_extensions because of missing coverage

* Refactored code based on suggestions

* Implemented suggested changes

* Implemented suggested changes

* Refactored code

* Refactored code

* Refactored code

* Refactored code

* refactored code

* Refactored code

* Refactored code in collection_domain.py

* Refactored code exp_domain.py

* Refactored code exp_services_test.py

* Refactored code

* Refactored code in platform_parameter_domain_test.py

* Refactored code in skill_domain_test.py

* Refactored code

* Refactored code in collection_domain.py

* Refactored string in story_domain_test.py

* refactored string in story_fetchers_test

* Refactored code in story_services_test

* Refactored code in suggestion_registry_test

* Refactor code suggestions_services_test

* Refactored code in summary_services_test

* Refactored code takeout_service_test

* Refactored strings

* Refactored strings

* Refactored strings

* Refactored strings

* Refactored strings

* Refactore strings

* Refactored string

* Refactored string

* Refactored Strings

* Refactored string in setup_test.py

* Refactored strings in stetup_test.py

* Refactored string in start.py

* Fixed linting errors

* Fixed skill_domain_test error

* Refactored code in suggestion_test.py

* Refactored string in task_test.py

* Refactored String

* Refactored email_manager_test

* Refactores trings feedback_services_test.py

* Refactored string story_domain.py

* Refactored sring in suggestions_services_test.py

* Implemented suggestions in story_services.py

* Fixed idenation error

* Refactored string in email_manager.py

* Refactored code suggestion_services.py

* Refactored code user_services_test.py

* Refactored code TextInput.py

* Refactored code in base_test

* Refactored code in objects.py

* Fixed linting issues in TextInput.py and base_test.py

* Implemented suggestion for PreventStringConcatenationCheckerTest

* Changed test function name in pylint_extensions_test

* Indented part of string for readability in commpn.py

* Refactored return string

* Refactored return string in js_ts_linter.py

* Refactored code to make this clearer
@Helper2020 Helper2020 mentioned this pull request Jul 8, 2024
65 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: Affects datastore layer Labels to indicate a PR that changes the datastore layer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants