# Github Actions, Flake8 and SonarCloud

**URL:** <https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810>\
**Category:** SonarQube Cloud\
**Created:** [April 16, 2021, 3:53pm UTC](https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810 "2021-04-16T15:53:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackg](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jackg](https://community.sonarsource.com/u/jackg)\
**Post date:** [April 16, 2021, 3:53pm UTC](https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810/1 "2021-04-16T15:53:34Z")

</div>

Hello, I am trying to import a flake8 txt report file into SonarCloud, as part of a Github Actions pipeline, using the following code:

[build.yml]

```auto
# Flake8
- name: Lint with flake8
  run: |
		flake8 --exit-zero --output-file=flake8.txt .

```

[sonar-project.properties]

```auto
sonar.python.flake8.reportPaths=/github/workspace/flake8.txt

```

But when I do so I get the following error:

```auto
17:02:21.307 INFO: Sensor Import of Flake8 issues [python]
17:02:21.334 ERROR: No issues information will be saved as the report file '/github/workspace/flake8.txt' can't be read. IllegalArgumentException: -1 is not a valid line offset for a file

```

And the flake8 info is not coming through to SonarCloud

Are you able to help with what the error means and how to fix it? Many thanks

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 16, 2021, 4:11pm UTC](https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810/2 "2021-04-16T16:11:51Z")

</div>

Hey there.

This would typically imply that some issue in the report is being reported as raised on a the -1st “something” of a file/line (a line number or column). Of course… that doesn’t make much sense. Anything look like this in your report file?

---

<div class="post-metadata">

**Author:** ![jackg](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jackg](https://community.sonarsource.com/u/jackg)\
**Post date:** [April 16, 2021, 4:51pm UTC](https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810/3 "2021-04-16T16:51:10Z")

</div>

Thanks Colin. We don’t see anything strange with the flake8.txt file - it’s many lines, each with this structure:

```auto
path/to/file.py:line:char: RULE description of rule

```

We were wondering if a blank line at the end of the flake8 report file might be causing the problem, so we tried:

[build.yml]

```auto
flake8 --exit-zero --output-file=flake8tmp.txt .
cat flake8tmp.txt| grep ^. > flake8.txt

```

But still get the same error

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 19, 2021, 8:38am UTC](https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810/4 "2021-04-19T08:38:41Z")

</div>

I’ve sent you a private message if you’d like to share your Flake8 report

---

<div class="post-metadata">

**Author:** ![jackg](https://avatars.discourse-cdn.com/v4/letter/j/8edcca/32.png) [@jackg](https://community.sonarsource.com/u/jackg)\
**Post date:** [April 28, 2021, 3:27pm UTC](https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810/5 "2021-04-28T15:27:30Z")

</div>

Thanks @Colin for your help with this!

For anyone else having similar problems, in my case the problem lines in flake8.txt were of the form:

`./path/to/file.py:21:0: F523 ‘…’.format(…) has unused arguments at position(s): 0`

and the problem is the column/character number of 0 in `./path/to/file.py:21:0...`

This column number of 0 comes from pyflakes, and results originally from a bug in cpython on Python 3.7, in how it handles column numbers for triple-quoted strings over multiple lines.

Solution for me is to exclude F523 from flake8 - in the longer term, upgrading to Python 3.8 would resolve the issue.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [April 28, 2021, 4:47pm UTC](https://community.sonarsource.com/t/github-actions-flake8-and-sonarcloud/41810/6 "2021-04-28T16:47:02Z")

</div>

Thanks for the wrap-up @jackg !

On my side, I’ll report. this to see if we want to do anything about it (for example, assume that a column of 0 can be safely corrected to 1).
