Swift rule override

I’m trying to override a rule ( Lines should not be too long) in my swift profile.

“maximumLineLength” 323 is ignored and the default value is used (120) while the severity is applied

sonarqube * Enterprise Edition* Version 8.7 (build 41497)

Any help please?

Hi @jma ,

Welcome to SonarSource Community! :sonarsource:

What quality profile is applied to your project/scan? Make sure the “Swift extend” profile is applied to your project.

If the project is already using that quality profile, can you please provide your scanner debug-level logs (just append -X to the sonar-scanner command)?


Hi @Joe,
Thanks, yes the profile is applied to the project.
Please find attached debug tracesscanner.log (36.6 KB)

Hi @jma ,

I could not replicate your issue on SonarQube EE 8.7. I created a new copy of the Sonar way (Swfit) quality profile and extended it with the same rule you used swift:s103 and modified the maximumLineLength to 323, applied the new quality profile to my project, and was able to trigger the code smell at info level:

Have you tried using SonarLint, bind your project to your SonarQube server, and see if you get the same issue?

If you are able to see your modified 323 character rule applied in SonarLint, then please see this: How do I trigger a full ElasticSearch reindex?

Forcing an Elasticsearch reindex fixes typical issues in the UI, so this may help you.

If you still can’t get it to work, can you try applying your quality profile to this sample project and add a 323 character long line and see if it works for you?


Hi @Joe,
Thanks, i can see that you have the same issue. Le code severity is overrided as expected (minor->info) but not maximumLineLength: 120 characters authorized while 323 is expected. Am i wrong?

l ran the scanner example with Swiftlint:

I’m not expecting this raise an issue since 174 characters is lower than the 200 maximum authorized

Hi @jma ,

Very strange, my screen doesn’t show that maximumLineLength variable:

I know I modified the rule and applied to that project:

And the rule is definitely applied here:

Please try this Elasticsearch reindex procedure and check your UI again and/or re-scan your project and modify just that one rule for maximum line length.


Hi @Joe,
Elasticsearch reindex did not solve the problem. The maximumLineLenght is still ignored. Lines with 127 and 174 characters should not trigger an issue.

Hi @jma ,

I think I’m able to replicate what you are doing now. It seems that when the severity is changed to “INFO” instead of the default “MAJOR”, then the issue will persist and ignore the custom maximumLineLength value. That is a minor bug that we can handle. I’ll report this to the devs.

EDIT: Actually, INFO level makes sense. From Issues:

Neither a bug nor a quality flaw, just a finding.

That means it’s a finding and not a true “issue” issue. Can you try adjusting the severity to not be INFO and see if the issue disappears (modify the quality profile, make sure the project uses that quality profile, rescan)?


EDIT: Oops, I reviewed your last screenshot that shows the issue with CRITICAL severity. I’ll add this to the notes when I mention it to the devs:

  • If the severity is left as the default MAJOR, then the adjusted maximumLineLength value is respected.
  • If any other severity is chosen (BLOCKER, CRITICAL, MINOR, INFO), then the adjusted maximumLineLength value is ignored and the issue is shown.

Hi @Joe
Thanks, i try to provide a detailed test:

  1. The use case
    I want to increase up to 200 characters the authorized maximum line length (default 120 characters) on swiftlint profile

  2. Method
    Apply to the project an overrided swiftlint profile and rule swift:S103 (Lines should not be too long) and set maximumLineLength: 200. This is the only one rule on this profile.
    A analyzed swift file with 3 test lines

  3. Test case 1: 56 characters
    Lower than 120 characters (and 200 :slight_smile: )
    let names = [“Chris”, “Alex”, “Ewa”, “Barry”, “Daniell”]
    Expected: no issue from S103

  4. Test case 2: 123 characters
    Greater than 120 characters but lower than 200 characters
    let names2 = [“Chris”, “Alex”, “Ewa”, “Barry”, “Daniella12345645651321654732152732132455321354521324113546313543213r14gez”]
    Expected: no issue from S103

  5. Test case 3: 203 characters
    let names3 = [“Chris”, “Alex”, “Ewa”, “Barry”, “Daniella12345645651321654732152732132455321354521324113546313543213r14gez4gqzegerqh3g1er1232131541320.2132143354543252he43rh5e3r2h1re3h54e3rh1r3eh2g1er3h”]
    Expected: issue raised from S103

  6. Tests
    Whatever severity is applied, S103 overridings seems to ignore de maximumLineLength and keep default value: 120 characters.
    Tests cases 2 & 3 raise an issue while only test 3 should.

Note: If the severity is changed on this overrided rule, it’s applied as expected

Hope this help