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

Programming exercises: Add Ruff SCA for Python to LocalCI #9573

Open
wants to merge 35 commits into
base: develop
Choose a base branch
from

Conversation

magaupp
Copy link
Contributor

@magaupp magaupp commented Oct 23, 2024

Checklist

General

Server

  • Important: I implemented the changes with a very good performance and prevented too many (unnecessary) and too complex database calls.
  • I strictly followed the server coding and design guidelines.
  • I added multiple integration tests (Spring) related to the features (with a high test coverage).
  • I documented the Java code using JavaDoc style.

Changes affecting Programming Exercises

  • High priority: I tested all changes and their related features with all corresponding user types on a test server configured with the integrated lifecycle setup (LocalVC and LocalCI).

Motivation and Context

Static Code Analysis is currently not supported for Python.

Description

This PR adds the Ruff static code analysis tool for Python.
Each issue is categorized according to its Ruff tool.

The PR also enables file overrides for static code analysis in exercise templates.

Steps for Testing

Prerequisites:

  • 1 Instructor
  • 1 Course
  1. Navigate to the exercise creation page
  2. Switch to advanced mode
  3. Select Python as the language
  4. Enable the check box for Enable Static Code Analysis
  5. Fill out the rest of the required fields
  6. Verify that the builds finish without errors
  7. Click on the Solution result
  8. Verify that 4 Code Issue warnings are displayed
  9. Close the feedback window
  10. Scroll to the top and click the Grading button
  11. Click the Code Analysis tab
  12. Verify that categories for each Ruff tool are shown

Testserver States

Note

These badges show the state of the test servers.
Green = Currently available, Red = Currently locked
Click on the badges to get to the test servers.







Review Progress

Performance Review

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Test Coverage

Server

Class/File Line Coverage Confirmation (assert/expect)
StaticCodeAnalysisConfigurer.java 99%
StaticCodeAnalysisTool.java 100%
ProgrammingExerciseRepositoryService.java 86%
LocalCIProgrammingLanguageFeatureService.java 100%
ParserPolicy.java 89%
RuffCategorizer.java 100%

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced support for Python-specific static code analysis using the "RUFF" tool.
    • Added a new script for static code analysis and testing in Python projects.
    • Enhanced repository setup to include static code analysis resources.
    • Implemented a new categorization strategy for the "RUFF" tool.
  • Bug Fixes

    • Improved handling of static code analysis reports and parsing for the "RUFF" tool.
  • Tests

    • Added unit tests for the "RUFF" parser to ensure accurate report handling.
  • Documentation

    • New JSON and SARIF files added to provide structured analysis results from the "RUFF" tool.

@github-actions github-actions bot added tests server Pull requests that update Java code. (Added Automatically!) config-change Pull requests that change the config in a way that they require a deployment via Ansible. template buildagent Pull requests that affect the corresponding module core Pull requests that affect the corresponding module programming Pull requests that affect the corresponding module labels Oct 23, 2024
@magaupp magaupp changed the title Programming exercises: Add Ruff SCA for Python Programming exercises: Add Ruff SCA for Python to LocalCI Oct 23, 2024
@magaupp magaupp force-pushed the feature/programming-exercises/python-sca branch from 41becc3 to 9802cae Compare October 23, 2024 20:48
Copy link

coderabbitai bot commented Oct 23, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 pmd (7.7.0)
src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java

The following rules are missing or misspelled in your ruleset file category/vm/bestpractices.xml: BooleanInstantiation, DontImportJavaLang, DuplicateImports, EmptyFinallyBlock, EmptyIfStmt, EmptyInitializer, EmptyStatementBlock, EmptyStatementNotInLoop, EmptySwitchStatements, EmptySynchronizedBlock, EmptyTryBlock, EmptyWhileStmt, ExcessiveClassLength, ExcessiveMethodLength, ImportFromSamePackage, MissingBreakInSwitch, SimplifyBooleanAssertion. Please check your ruleset configuration.

Walkthrough

The pull request introduces enhancements to support Python-specific static code analysis within the existing framework. Key additions include the RUFF static code analysis tool, new category definitions for Python, and modifications to various services and configurations to integrate these changes. A new Bash script for static analysis operations is also included, alongside updates to unit tests and expected results for the RUFF tool.

Changes

File Change Summary
src/main/java/de/tum/cit/aet/artemis/core/config/StaticCodeAnalysisConfigurer.java Added support for Python static code analysis with new categories and a method to create default categories.
src/main/java/de/tum/cit/aet/artemis/programming/domain/StaticCodeAnalysisTool.java Introduced RUFF tool to the static analysis tools enum and updated the programming language mapping.
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseRepositoryService.java Enhanced repository service to manage static code analysis resources and updated the record structure.
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCIProgrammingLanguageFeatureService.java Modified configuration for Python programming language features.
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/scaparser/strategy/ParserPolicy.java Updated to handle RUFF in the parsing strategy for static code analysis.
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/scaparser/strategy/sarif/RuffCategorizer.java Introduced RuffCategorizer class for categorizing rules from RUFF.
src/main/resources/templates/aeolus/python/default_static.sh Added a new Bash script for static analysis and testing of Python projects.
src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java Added a test for the RUFF parser functionality.
src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseFactory.java Updated to handle RUFF in static code analysis issue generation.
src/test/resources/test-data/static-code-analysis/expected/ruff.json Introduced a new JSON file with static code analysis results from RUFF.
src/test/resources/test-data/static-code-analysis/reports/ruff.sarif Added a SARIF report detailing errors identified by the RUFF tool.

Possibly related PRs

Suggested labels

client, documentation, bugfix

Suggested reviewers

  • SimonEntholzer
  • az108
  • JohannesStoehr
  • b-fein
  • krusche

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between abce358 and 60d5164.

📒 Files selected for processing (1)
  • src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

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.

@magaupp magaupp force-pushed the feature/programming-exercises/python-sca branch from 9802cae to 9d809ef Compare October 27, 2024 12:35
@magaupp magaupp changed the base branch from develop to feature/programming-exercises/sarif-parser October 27, 2024 12:39
@magaupp magaupp added the stacked-pr PR that depends on another PR label Oct 27, 2024
@magaupp magaupp mentioned this pull request Oct 27, 2024
13 tasks
@magaupp magaupp force-pushed the feature/programming-exercises/python-sca branch from 70fbb8f to 7cc3748 Compare December 5, 2024 22:05
@magaupp magaupp removed the stacked-pr PR that depends on another PR label Dec 5, 2024
@magaupp magaupp temporarily deployed to artemis-test3.artemis.cit.tum.de December 6, 2024 00:34 — with GitHub Actions Inactive
@magaupp magaupp marked this pull request as ready for review December 6, 2024 00:43
@magaupp magaupp requested a review from a team as a code owner December 6, 2024 00:43
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: 5

🧹 Outside diff range and nitpick comments (8)
src/main/resources/templates/aeolus/python/default_static.sh (3)

1-3: Consider hardening the shell script setup

While the basic setup is good, consider adding these safety flags for more robust error handling:

 #!/usr/bin/env bash
-set -e
+set -euo pipefail
 export AEOLUS_INITIAL_DIRECTORY=${PWD}

18-30: Improve directory handling safety

The current directory handling could be safer with proper error checking and cleanup.

 main () {
   if [[ "${1}" == "aeolus_sourcing" ]]; then
     return 0 # just source to use the methods in the subshell, no execution
   fi
   local _script_name
   _script_name=${BASH_SOURCE[0]:-$0}
+  
+  # Ensure we return to initial directory on exit
+  trap 'cd "${AEOLUS_INITIAL_DIRECTORY}"' EXIT
+  
+  # Validate directory exists
+  if [[ ! -d "${AEOLUS_INITIAL_DIRECTORY}" ]]; then
+    echo "Error: Initial directory not found" >&2
+    return 1
+  fi
+  
   cd "${AEOLUS_INITIAL_DIRECTORY}"
   bash -c "source ${_script_name} aeolus_sourcing; static_code_analysis"
-  cd "${AEOLUS_INITIAL_DIRECTORY}"
   bash -c "source ${_script_name} aeolus_sourcing; build_and_test_the_code"
 }

1-30: Consider separating configuration from execution

While the script implements the required functionality for Python static code analysis, consider these architectural improvements:

  1. Move the Ruff configuration options to a separate configuration file
  2. Add support for environment variables to override default settings
  3. Consider implementing a logging mechanism for better debugging

This would improve maintainability and flexibility of the static analysis implementation.

🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 6-6: studentParentWorkingDirectoryName is referenced but not assigned.

(SC2154)

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseRepositoryService.java (2)

119-120: Consider refactoring RepositoryResources for better maintainability

The RepositoryResources record now contains seven fields, which might make it harder to manage and understand. Consider encapsulating related fields into separate records or classes to improve code clarity and maintainability.


334-340: Enhance comment clarity for resource copying sections

To improve readability, consider separating comments for the project type and static code analysis resource copying sections:

// Copy project type specific files
if (repositoryResources.projectTypeResources != null) {
    fileService.copyResources(repositoryResources.projectTypeResources, repositoryResources.projectTypePrefix, repoLocalPath, true);
}

// Copy static code analysis specific files
if (repositoryResources.staticCodeAnalysisResources != null) {
    fileService.copyResources(repositoryResources.staticCodeAnalysisResources, repositoryResources.staticCodeAnalysisPrefix, repoLocalPath, true);
}

This makes it clear that the two blocks handle different resource types.

src/test/resources/test-data/static-code-analysis/expected/ruff.json (1)

5-13: Use relative file paths in test data for portability

Using absolute file paths like /usr/local/src/exercise/policy.py in test data may lead to issues when running tests in different environments. Consider replacing them with relative paths to improve portability:

"filePath": "exercise/policy.py",

This change ensures that the test data remains valid regardless of the file system structure.

src/main/java/de/tum/cit/aet/artemis/core/config/StaticCodeAnalysisConfigurer.java (1)

17-78: Consider prioritizing categories with different penalty weights

The comprehensive list of Python categories is good, but consider grouping them by severity and assigning different penalty weights. For example:

  • Critical (higher penalty): security-related categories like "flake8-bandit"
  • Major (medium penalty): code correctness like "Pyflakes"
  • Minor (lower penalty): style-related like "pycodestyle"
src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseFactory.java (1)

344-344: Use a more appropriate default category for RUFF

Using "Pylint" as the category for RUFF tool might be confusing since they are different tools. Consider using a more generic category like "Code Quality" or one of RUFF's native categories.

-            case RUFF -> "Pylint";
+            case RUFF -> "Pyflakes";  // Using Pyflakes as it's one of RUFF's core rules
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8036d43 and abce358.

⛔ Files ignored due to path filters (3)
  • src/main/resources/config/application.yml is excluded by !**/*.yml
  • src/main/resources/templates/aeolus/python/default_static.yaml is excluded by !**/*.yaml
  • src/main/resources/templates/python/staticCodeAnalysis/test/ruff-student.toml is excluded by !**/*.toml
📒 Files selected for processing (11)
  • src/main/java/de/tum/cit/aet/artemis/core/config/StaticCodeAnalysisConfigurer.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/domain/StaticCodeAnalysisTool.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseRepositoryService.java (6 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCIProgrammingLanguageFeatureService.java (1 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/localci/scaparser/strategy/ParserPolicy.java (2 hunks)
  • src/main/java/de/tum/cit/aet/artemis/programming/service/localci/scaparser/strategy/sarif/RuffCategorizer.java (1 hunks)
  • src/main/resources/templates/aeolus/python/default_static.sh (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java (1 hunks)
  • src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseFactory.java (1 hunks)
  • src/test/resources/test-data/static-code-analysis/expected/ruff.json (1 hunks)
  • src/test/resources/test-data/static-code-analysis/reports/ruff.sarif (1 hunks)
🧰 Additional context used
📓 Path-based instructions (8)
src/test/java/de/tum/cit/aet/artemis/programming/util/ProgrammingExerciseFactory.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java (1)

Pattern src/test/java/**/*.java: test_naming: descriptive; test_size: small_specific; fixed_data: true; junit5_features: true; assert_use: assertThat; assert_specificity: true; archunit_use: enforce_package_rules; db_query_count_tests: track_performance; util_service_factory_pattern: true; avoid_db_access: true; mock_strategy: static_mocks; context_restart_minimize: true

src/main/java/de/tum/cit/aet/artemis/programming/domain/StaticCodeAnalysisTool.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCIProgrammingLanguageFeatureService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/scaparser/strategy/ParserPolicy.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/scaparser/strategy/sarif/RuffCategorizer.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseRepositoryService.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

src/main/java/de/tum/cit/aet/artemis/core/config/StaticCodeAnalysisConfigurer.java (1)

Pattern src/main/java/**/*.java: naming:CamelCase; principles:{single_responsibility,small_methods,no_duplication}; db:{perf_queries,datetime_not_timestamp}; rest:{stateless,singleton,delegate_logic,http_only,minimal_dtos}; dtos:{java_records,no_entities,min_data,single_resp}; di:constructor_injection; kiss:simple_code; file_handling:os_indep_paths; practices:{least_access,avoid_transactions,code_reuse,static_member_ref,prefer_primitives}; sql:{param_annotation,uppercase,avoid_subqueries};java:avoid_star_imports

📓 Learnings (1)
src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCIProgrammingLanguageFeatureService.java (1)
Learnt from: magaupp
PR: ls1intum/Artemis#9261
File: src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCIProgrammingLanguageFeatureService.java:43-55
Timestamp: 2024-11-12T12:51:40.391Z
Learning: For constructors with multiple boolean parameters, it's acceptable to keep them as is because parameter names are clear and IDEs provide inline hints, making the code readable without refactoring to the builder pattern.
🪛 Shellcheck (0.10.0)
src/main/resources/templates/aeolus/python/default_static.sh

[warning] 6-6: studentParentWorkingDirectoryName is referenced but not assigned.

(SC2154)

🔇 Additional comments (15)
src/main/java/de/tum/cit/aet/artemis/programming/service/ProgrammingExerciseRepositoryService.java (6)

52-53: Definition of STATIC_CODE_ANALYSIS_DIR constant is appropriate

The addition of the STATIC_CODE_ANALYSIS_DIR constant enhances code maintainability by centralizing the directory name.


134-134: Variable renaming enhances clarity

Renaming projectTypeTemplateDir to repositoryTypeTemplateDir improves readability by accurately reflecting the variable's purpose.


141-141: Path resolution uses the correct template directory

The use of repositoryTypeTemplateDir in path resolution ensures that the correct repository type templates are accessed.


144-144: Prefix path correctly incorporates repository type

The prefix variable now accurately includes the repository type, aligning with the updated directory structure.


155-156: Project type paths are correctly resolved

The variables projectTypeSpecificPrefix and projectTypeTemplatePath correctly use repositoryTypeTemplateDir, ensuring proper path resolution for project-specific resources.


171-183: Static code analysis resources are conditionally loaded

The addition of static code analysis resources is correctly implemented with a conditional check, ensuring resources are only loaded when static code analysis is enabled.

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/scaparser/strategy/ParserPolicy.java (1)

32-32: Integration of RUFF parser is correctly implemented

The addition of the RUFF case with a new SarifParser and RuffCategorizer correctly integrates RUFF support into the parser configuration.

src/test/resources/test-data/static-code-analysis/expected/ruff.json (1)

54-56: Handle unknown categories appropriately in test data

The rule X999 with category "Unknown" is correctly included to test how the system handles unknown categories, ensuring robustness in the parsing logic.

src/main/java/de/tum/cit/aet/artemis/programming/domain/StaticCodeAnalysisTool.java (1)

21-21: RUFF tool added to the StaticCodeAnalysisTool enum and mapped correctly

The addition of RUFF to the enum and its association with ProgrammingLanguage.PYTHON appropriately extends static code analysis support for Python exercises.

Also applies to: 31-31

src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java (1)

77-80: LGTM! Test follows established patterns

The new test method is well-structured, follows the existing test patterns, and maintains consistency with other parser tests in the class.

src/main/java/de/tum/cit/aet/artemis/programming/service/localci/LocalCIProgrammingLanguageFeatureService.java (1)

56-56: LGTM! Python features correctly updated for SCA support

The update to Python's language features correctly enables static code analysis support, aligning with the PR's objective of adding Ruff SCA.

src/test/resources/test-data/static-code-analysis/reports/ruff.sarif (3)

1-3: LGTM! Valid SARIF schema reference

The file correctly references the SARIF 2.1.0 schema, ensuring proper format validation.


5-115: Comprehensive test cases for Python static analysis

The test cases cover important Python-specific issues:

  • Wildcard imports (F403)
  • Magic numbers (PLR2004)
  • Undefined names from star imports (F405)
  • Generic error case (X999)

This provides good coverage for testing the Ruff parser implementation.


117-190: Well-documented rules with detailed explanations

Each rule includes:

  • Full descriptions with examples
  • Help text
  • Documentation links
  • Severity levels
  • Rule categories

This comprehensive documentation will help developers understand and fix the reported issues.

src/main/java/de/tum/cit/aet/artemis/core/config/StaticCodeAnalysisConfigurer.java (1)

82-83: LGTM!

The addition of Python to the language-specific categories map is clean and follows the existing pattern.

coderabbitai[bot]
coderabbitai bot previously approved these changes Dec 6, 2024
# Conflicts:
#	src/test/java/de/tum/cit/aet/artemis/programming/StaticCodeAnalysisParserUnitTest.java
Copy link
Contributor

@SimonEntholzer SimonEntholzer left a comment

Choose a reason for hiding this comment

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

Tested on Ts1, works as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config-change Pull requests that change the config in a way that they require a deployment via Ansible. core Pull requests that affect the corresponding module deploy:artemis-test1 programming Pull requests that affect the corresponding module ready for review server Pull requests that update Java code. (Added Automatically!) template tests
Projects
Status: Ready For Review
Status: In review
Development

Successfully merging this pull request may close these issues.

3 participants