nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: MarketSquare/robotframework-robocop
Pull request #1350 (2025-03-24 16:40:34)

Fix language not loaded in linter


Patch:
diff --git a/src/robocop/linter/runner.py b/src/robocop/linter/runner.py
index 8d0781a..d796ddb 100644
--- a/src/robocop/linter/runner.py
+++ b/src/robocop/linter/runner.py
@@ -11,6 +11,7 @@ from robocop.linter import reports
 from robocop.linter.diagnostics import Diagnostics
 from robocop.linter.reports import save_reports_result_to_cache
 from robocop.linter.utils.disablers import DisablersFinder
+from robocop.linter.utils.file_types import get_resource_with_lang
 from robocop.linter.utils.misc import is_suite_templated
 
 if TYPE_CHECKING:
@@ -30,15 +31,14 @@ class RobocopLinter:
         self.diagnostics: list[Diagnostic] = []
         self.configure_reports()
 
-    def get_model_for_file_type(self, source: Path) -> File:
+    def get_model_for_file_type(self, source: Path, language: list[str] | None) -> File:
         """Recognize model type of the file and load the model."""
         # TODO: decide to migrate file type recognition based on imports from robocop
-        # TODO: language
         if "__init__" in source.name:
-            return get_init_model(source)
+            return get_resource_with_lang(get_init_model, source, language)
         if source.suffix == ".resource":
-            return get_resource_model(source)
-        return get_model(source)
+            return get_resource_with_lang(get_resource_model, source, language)
+        return get_resource_with_lang(get_model, source, language)
 
     def run(self) -> list[Diagnostic]:
         issues_no = 0
@@ -47,7 +47,7 @@ class RobocopLinter:
             if config.verbose:
                 print(f"Scanning file: {source}")
             try:
-                model = self.get_model_for_file_type(source)
+                model = self.get_model_for_file_type(source, config.language)
             except DataError:
                 print(
                     f"Failed to decode {source}. Default supported encoding by Robot Framework is UTF-8. Skipping file"


Test patch:
diff --git a/tests/linter/rules/naming/invalid_section/test_lang_no_header.resource b/tests/linter/rules/naming/invalid_section/test_lang_no_header.resource
new file mode 100644
index 0000000..0b114f8
--- /dev/null
+++ b/tests/linter/rules/naming/invalid_section/test_lang_no_header.resource
@@ -0,0 +1,5 @@
+*** Przypadki Testowe ***
+Test case
+    Step
+
+*** Ustawienia ***
\ No newline at end of file
diff --git a/tests/linter/rules/naming/invalid_section/test_rule.py b/tests/linter/rules/naming/invalid_section/test_rule.py
index 92bedac..4516739 100644
--- a/tests/linter/rules/naming/invalid_section/test_rule.py
+++ b/tests/linter/rules/naming/invalid_section/test_rule.py
@@ -14,3 +14,8 @@ class TestRuleAcceptance(RuleAcceptance):
             output_format="extended",
             test_on_version=">=6.1",
         )
+
+    def test_rule_lang_no_header(self):
+        self.check_rule(
+            src_files=["test_lang_no_header.resource"], language=["pl"], expected_file=None, test_on_version=">=6.1"
+        )
Repository: MarketSquare/robotframework-robocop
Pull request #1359 (2025-03-27 10:53:50)

Fix return_status report
#1357


Patch:
diff --git a/docs/releasenotes/6.0.1.rst b/docs/releasenotes/6.0.1.rst
new file mode 100644
index 0000000..d4a6f18
--- /dev/null
+++ b/docs/releasenotes/6.0.1.rst
@@ -0,0 +1,26 @@
+:orphan:
+
+=============
+Robocop 6.0.1
+=============
+
+return_status report fails with no attribute exception (#1357)
+--------------------------------------------------------------
+
+``return_status`` report should no longer fail with `has no exit_code` attribute error.
+
+
+Acknowledgements
+================
+
+Thanks to the whole community for submitting bug reports and feature requests.
+Without you, Robocop wouldn't be in the place where it is now. All the feedback
+is essential to drive the tool towards higher quality and better user
+experience.
+
+If you want to help us more, consider contributing to the project directly.
+We can offer our constant support to make the work fun and effective. We do
+our best to create a supportive and welcoming environment for everyone.
+Feel free to ping us on our official `#robocop-linter Slack channel`_ anytime.
+
+.. _#robocop-linter Slack channel: https://robotframework.slack.com/archives/C01AWSNKC2H
\ No newline at end of file
diff --git a/src/robocop/linter/runner.py b/src/robocop/linter/runner.py
index d796ddb..20e6d71 100644
--- a/src/robocop/linter/runner.py
+++ b/src/robocop/linter/runner.py
@@ -122,7 +122,7 @@ class RobocopLinter:
         if self.config_manager.default_config.linter.exit_zero:
             exit_code = 0
         elif "return_status" in self.reports:
-            exit_code = self.reports["return_status"].exit_code
+            exit_code = self.reports["return_status"].return_status
         else:
             exit_code = 1 if issues_count else 0
         raise typer.Exit(code=exit_code)


Test patch:
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 0633496..03189de 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -4,6 +4,7 @@ from typer.testing import CliRunner
 
 from robocop import __version__
 from robocop.run import app
+from tests import working_directory
 
 
 def test_version():
@@ -73,3 +74,9 @@ class TestListFormatters:
         assert result.exit_code == 0
         assert "NormalizeNewLines" in result.stdout
         assert "ReplaceReturns" not in result.stdout
+
+    def test_return_status(self, tmp_path):
+        runner = CliRunner()
+        with working_directory(tmp_path):
+            result = runner.invoke(app, ["check", "--reports", "return_status"])
+        assert result.exit_code == 0