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

[ENH] add new UI #313

Merged
merged 32 commits into from
May 28, 2024
Merged

[ENH] add new UI #313

merged 32 commits into from
May 28, 2024

Conversation

Remi-Gau
Copy link
Owner

No description provided.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @Remi-Gau - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 8 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 6 issues found
  • 🟡 Complexity: 1 issue found

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

"CogPOID": "",
"InstitutionName": "",
"InstitutionAddress": "",
"InstitutionalDepartmentName": ""
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Empty string values

Consider removing keys with empty string values or providing meaningful default values.

Suggested change
"InstitutionalDepartmentName": ""
{
"CogPOID": "",
"InstitutionName": "",
"InstitutionAddress": "",
"InstitutionalDepartmentName": null
}

from ecobidas_ui._version import version
from ecobidas_ui.extensions import bootstrap, csrf_protect

# from ecobidas_ui.extensions import cache, debug_toolbar
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Remove commented-out import statements

Commented-out import statements can be removed to keep the code clean and maintainable. If these imports are not needed, consider removing them.

Suggested change
# from ecobidas_ui.extensions import cache, debug_toolbar
from ecobidas_ui._version import version
from ecobidas_ui.extensions import bootstrap, csrf_protect
from ecobidas_ui.initializers.assets import init_assets
from flask import Flask, flash, render_template

blueprint = Blueprint("generate", __name__, url_prefix="/generate")


def dummmy_data():
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (typo): Typo in function name 'dummmy_data'

The function name 'dummmy_data' contains a typo. Consider renaming it to 'dummy_data' for clarity and correctness.

ui/ecobidas_ui/generate/views.py Outdated Show resolved Hide resolved
ui/ecobidas_ui/public/views.py Outdated Show resolved Hide resolved
submit_bold_json = SubmitField("Upload")


def generate_form(items=None, prefix=None, obj=None) -> FlaskForm:
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Low code quality found in generate_form - 17% (low-code-quality)


ExplanationThe quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

ui/ecobidas_ui/protocols/utils.py Outdated Show resolved Hide resolved
ui/ecobidas_ui/protocols/utils.py Outdated Show resolved Hide resolved


@blueprint.post("/<protocol_name>/<activity_name>")
def activity_post(protocol_name, activity_name) -> str:
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Low code quality found in activity_post - 14% (low-code-quality)


ExplanationThe quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

Comment on lines 225 to 235
message = f"2 files must be uploaded. Received: {nb_files_uploaded}"
return message

participants_json_uploaded = any(file.filename == "participants.json" for file in data)
if not participants_json_uploaded:
message = "No 'participants.json' was uploaded."
return message

participants_tsv_uploaded = any(file.filename == "participants.tsv" for file in data)
if not participants_tsv_uploaded:
message = "No 'participants.tsv' was uploaded."
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): Inline variable that is immediately returned [×3] (inline-immediately-returned-variable)

@Remi-Gau Remi-Gau merged commit 5fb3118 into main May 28, 2024
5 checks passed
@Remi-Gau Remi-Gau deleted the ui branch May 28, 2024 14:22
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