# Unexpected arguments due to sonar pointing to the wrong module (python:S930)

**URL:** <https://community.sonarsource.com/t/unexpected-arguments-due-to-sonar-pointing-to-the-wrong-module-python-s930/42360>\
**Category:** SonarQube Cloud\
**Tags:** monorepo, python, modules\
**Created:** [April 27, 2021, 4:20pm UTC](https://community.sonarsource.com/t/unexpected-arguments-due-to-sonar-pointing-to-the-wrong-module-python-s930/42360 "2021-04-27T16:20:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cwanyo](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/cwanyo/32/21604_2.png) [@Cwanyo](https://community.sonarsource.com/u/Cwanyo)\
**Post date:** [April 27, 2021, 4:20pm UTC](https://community.sonarsource.com/t/unexpected-arguments-due-to-sonar-pointing-to-the-wrong-module-python-s930/42360/1 "2021-04-27T16:20:39Z")

</div>

I have monorepo setup where each module might have the duplicate file name + function name but different in arguments.

![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/3X/d/1/d1fbd76662239d40a9e5d286b01659f8ae74fb9e.png)  
[\> sample code here](https://sonarcloud.io/code?id=Cwanyo_py-sonar)

It seems like sonar have a problem pointing to a correct module and report the issues as ‘unexpected arguments’ (python: S930) due to the function receives different arguments.  
[\> issue on sonarcloud](https://sonarcloud.io/project/issues?id=Cwanyo_py-sonar&open=AXkT3CQdBofSoPBkjcYO)

I tried to define the modules in .sonarcloud.properties as below, But it doesn’t seem to be working.

```auto
sonar.modules=module-a,module-b
module-a.sonar.projectName=module-a
module-a.sonar.sources=module-a/
module-b.sonar.projectName=module-b
module-b.sonar.sources=module-b/

```

Any help would be appreciated.

Thank you.

---

<div class="post-metadata">

**Author:** ![Guillaume\_Dequenne](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/guillaume_dequenne/32/7472_2.png) [@Guillaume\_Dequenne](https://community.sonarsource.com/u/Guillaume_Dequenne)\
**Post date:** [April 30, 2021, 2:37pm UTC](https://community.sonarsource.com/t/unexpected-arguments-due-to-sonar-pointing-to-the-wrong-module-python-s930/42360/2 "2021-04-30T14:37:20Z")

</div>

Hello @Cwanyo

First of all, welcome to this community and many thanks to you for the clear reproducer.

This feedback is coming at quite an appropriate time, as we are about to start some work on improving symbol resolution for Python analysis.

First, to address your issue, I believe what you want to do is to set up a monorepo in SonarCloud.

Your reproducer is currently analyzed with automatic analysis and is seen by SonarCloud as a single project, which is probably not what you want when working with monorepos.

Instead, you can set up multiple projects that are analyzed separately. For that, unfortunately automatic analysis is not available.

Here is some documentation about how to set up a monorepo:  
[https://sonarcloud.io/documentation/analysis/setup-monorepo/](https://sonarcloud.io/documentation/analysis/setup-monorepo/)  
[https://blog.sonarsource.com/mono-repository-support-for-github-and-azure-devops](https://blog.sonarsource.com/mono-repository-support-for-github-and-azure-devops)

Also, here is an example setup based on your reproducer:

> **[guillaume-dequenne-sonarsource/py-sonar](https://github.com/guillaume-dequenne-sonarsource/py-sonar)**
>
> Contribute to guillaume-dequenne-sonarsource/py-sonar development by creating an account on GitHub.

The analysis is triggered by a Github Action (as automatic analysis is not available for monorepos - feel free to replace this with your preferred CI-based analysis configuration) and there are 2 sub-projects that are analyzed separately, each with their own `sonar-project.properties`. Also, `.sonarcloud.properties` is no longer needed.

There, we can see that the false positive is gone. I also introduced actual bugs in both projects which are correctly detected:

[https://sonarcloud.io/project/issues?id=guillaume-dequenne-sonarsource\_py-sonar\_1&open=AXkiy0lFrLqyxp--grJZ&resolved=false&types=BUG](https://sonarcloud.io/project/issues?id=guillaume-dequenne-sonarsource_py-sonar_1&open=AXkiy0lFrLqyxp--grJZ&resolved=false&types=BUG)  
[https://sonarcloud.io/project/issues?id=guillaume-dequenne-sonarsource\_py-sonar\_2&open=AXki017xvbT53MIh7Wo7&resolved=false&types=BUG](https://sonarcloud.io/project/issues?id=guillaume-dequenne-sonarsource_py-sonar_2&open=AXki017xvbT53MIh7Wo7&resolved=false&types=BUG)

That being said, your reproducer still highlights a bug in the way our analyzer resolves symbols, as the same pattern could happen in a regular project.

Mostly, this is due to the fact that our analyzer doesn’t compute the correct fully qualified names for modules if no ` __init__.py` is present in the package. In turn, this bug hid another bug which prevents our analyzer from correctly resolving imported symbols in some cases.

For that, I have created the following tickets: [SONARPY-844](https://jira.sonarsource.com/browse/SONARPY-844) and [SONARPY-846](https://jira.sonarsource.com/browse/SONARPY-846) which we will hopefully tackle soon.

Thanks again for your feedback,

Hope that helps,  
Guillaume

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [May 7, 2021, 2:37pm UTC](https://community.sonarsource.com/t/unexpected-arguments-due-to-sonar-pointing-to-the-wrong-module-python-s930/42360/3 "2021-05-07T14:37:47Z")

</div>

Closed on May 7, 2021, 2:37pm UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
