Repository: MarketSquare/robotframework-robocop
Pull request #785 (2023-02-27 13:28:55)

Fix non-path option values resolved as a path in argument files
Last release introduced regression. This PR introduces fix and next fix release (since it could break pipelines if someones uses Robocop argumentfile and always instant most recent version). 

The bug was in forcefully resolving option values as a path even if they are not a path. For example if you had configuration:

```
--configure rule:param:value
```

Robocop would read it as:

```
--configure path/to/configuration.file/rule:param:value
```


codecov-commenter: # [Codecov](https://codecov.io/gh/MarketSquare/robotframework-robocop/pull/785?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare) Report
Base: **96.89**% // Head: **96.89**% // Increases project coverage by **`+0.00%`** :tada:
> Coverage data is based on head [(`84bf93a`)](https://codecov.io/gh/MarketSquare/robotframework-robocop/pull/785?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare) compared to base [(`c380b14`)](https://codecov.io/gh/MarketSquare/robotframework-robocop/commit/c380b142f5c15bd2f1034b0300a1a247215bbb12?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare).
> Patch coverage: 100.00% of modified lines in pull request are covered.

> :exclamation: Current head 84bf93a differs from pull request most recent head 38d71c6. Consider uploading reports for the commit 38d71c6 to get more accurate results

:mega: This organization is not using Codecov’s [GitHub App Integration](https://github.com/apps/codecov). We recommend you install it so Codecov can continue to function properly for your repositories. [Learn more](https://about.codecov.io/blog/codecov-is-updating-its-github-integration/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare)

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master     #785   +/-   ##
=======================================
  Coverage   96.89%   96.89%           
=======================================
  Files          24       24           
  Lines        3256     3257    +1     
=======================================
+ Hits         3155     3156    +1     
  Misses        101      101           
```


| [Impacted Files](https://codecov.io/gh/MarketSquare/robotframework-robocop/pull/785?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare) | Coverage Δ | |
|---|---|---|
| [robocop/config.py](https://codecov.io/gh/MarketSquare/robotframework-robocop/pull/785?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare#diff-cm9ib2NvcC9jb25maWcucHk=) | `94.55% <100.00%> (+0.01%)` | :arrow_up: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare)

</details>

[:umbrella: View full report at Codecov](https://codecov.io/gh/MarketSquare/robotframework-robocop/pull/785?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare).   
:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=MarketSquare).


Patch:
diff --git a/docs/releasenotes/2.8.1.rst b/docs/releasenotes/2.8.1.rst
new file mode 100644
index 0000000..6c6f608
--- /dev/null
+++ b/docs/releasenotes/2.8.1.rst
@@ -0,0 +1,15 @@
+:orphan:
+
+Robocop 2.8.1
+================
+
+Recent update to configuration argument files introduces a bug where option values were appended by a path to the
+argument file directory. It should be fixed with this release.
+
+You can install the latest available version by running::
+
+    pip install --upgrade robotframework-robocop
+
+or to install exactly this version::
+
+    pip install robotframework-robocop==2.8.1
diff --git a/robocop/config.py b/robocop/config.py
index 5044f51..ea2237a 100644
--- a/robocop/config.py
+++ b/robocop/config.py
@@ -133,12 +133,16 @@ class ArgumentFileParser:
         prev_arg = "option"
         resolved = []
         for arg in args:
-            if (prev_option_like and prev_arg in self.RESOLVE_PATHS_OPTIONS) or prev_option_like:
+            option_like = arg.startswith("-")
+            # resolve path if previous arg was an option that can be path, or the arg is a source
+            if (prev_option_like and prev_arg in self.RESOLVE_PATHS_OPTIONS) or (  # option value that can be path
+                not prev_option_like and not option_like  # source
+            ):
                 ensure_exists = prev_arg in self.ENSURE_EXIST_PATHS_OPTIONS
                 # TODO: If the --rules is provided as comma separated list, it will not resolve paths
                 arg = resolve_relative_path(arg, root_dir, ensure_exists)
             resolved.append(arg)
-            prev_option_like = arg.startswith("-")
+            prev_option_like = option_like
             prev_arg = arg
         return resolved
 


Test patch:
diff --git a/tests/test_data/argument_file/base.txt b/tests/test_data/argument_file/base.txt
index 1c07077..3aa9e23 100644
--- a/tests/test_data/argument_file/base.txt
+++ b/tests/test_data/argument_file/base.txt
@@ -1,1 +1,2 @@
---ext-rules rflinter.robocop.naming
\ No newline at end of file
+--ext-rules rflinter.robocop.naming
+--configure too-long-test-case:severity:I
\ No newline at end of file
diff --git a/tests/utest/test_default_config.py b/tests/utest/test_default_config.py
index b4934d9..b1e6066 100644
--- a/tests/utest/test_default_config.py
+++ b/tests/utest/test_default_config.py
@@ -244,3 +244,4 @@ def test_nested_argument_files(path_to_test_data):
     ):
         config = Config(from_cli=True)
         assert config.ext_rules == {"rflinter.robocop.spacing", "rflinter.robocop.naming"}
+        assert config.configure == ["too-long-test-case:severity:I"]