From 8daf531443771ac6fa1e2bc5a4b926a1c9afa326 Mon Sep 17 00:00:00 2001 From: robertomarcos-diverger Date: Wed, 19 Nov 2025 17:50:11 +0100 Subject: [PATCH] Fix SonarQube issues in src/codeas/ui/components/repo_ui.py --- src/codeas/ui/components/repo_ui.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/codeas/ui/components/repo_ui.py b/src/codeas/ui/components/repo_ui.py index 1261c37..25c430d 100644 --- a/src/codeas/ui/components/repo_ui.py +++ b/src/codeas/ui/components/repo_ui.py @@ -6,6 +6,9 @@ from codeas.core.state import state +COLUMN_INCL_KEY = "Incl." + + def display(): display_repo_path() display_files() @@ -25,11 +28,11 @@ def display_files(): def get_selected_files_info(): - num_selected_files = sum(state.files_data["Incl."]) - total_files = len(state.files_data["Incl."]) + num_selected_files = sum(state.files_data[COLUMN_INCL_KEY]) + total_files = len(state.files_data[COLUMN_INCL_KEY]) selected_tokens = sum( token - for incl, token in zip(state.files_data["Incl."], state.files_data["Tokens"]) + for incl, token in zip(state.files_data[COLUMN_INCL_KEY], state.files_data["Tokens"]) if incl ) return num_selected_files, total_files, selected_tokens @@ -68,7 +71,7 @@ def display_files_editor(): state.files_data, use_container_width=True, column_config={ - "Incl.": st.column_config.CheckboxColumn(width=5), + COLUMN_INCL_KEY: st.column_config.CheckboxColumn(width=5), "Path": st.column_config.TextColumn(width="large"), "Tokens": st.column_config.NumberColumn(width=5), }, @@ -83,7 +86,7 @@ def display_metadata_editor(files_metadata): files_metadata, use_container_width=True, column_config={ - "Incl.": st.column_config.CheckboxColumn(width=5), + COLUMN_INCL_KEY: st.column_config.CheckboxColumn(width=5), "Path": st.column_config.TextColumn(width="large"), "Tokens": st.column_config.NumberColumn(width=5), }, @@ -95,14 +98,14 @@ def display_metadata_editor(files_metadata): def sort_files_data(): sorted_data = sorted( zip( - state.files_data["Incl."], + state.files_data[COLUMN_INCL_KEY], state.files_data["Path"], state.files_data["Tokens"], ), key=lambda x: (not x[0], x[1]), ) ( - state.files_data["Incl."], + state.files_data[COLUMN_INCL_KEY], state.files_data["Path"], state.files_data["Tokens"], ) = zip(*sorted_data) @@ -111,14 +114,14 @@ def sort_files_data(): def sort_files_metadata(files_metadata): sorted_data = sorted( zip( - files_metadata["Incl."], + files_metadata[COLUMN_INCL_KEY], files_metadata["Path"], files_metadata["Tokens"], ), key=lambda x: (not x[0], x[1]), ) ( - files_metadata["Incl."], + files_metadata[COLUMN_INCL_KEY], files_metadata["Path"], files_metadata["Tokens"], - ) = zip(*sorted_data) + ) = zip(*sorted_data) \ No newline at end of file