Resolving "The file header copyright text should match the copyright text from the settings"

Sorry I’m late again on this one. If it’s a private project, I don’t have access to it. Access to private customer projects is limited inside the company.

I don’t understand - the screenshot is about Cognitive Complexity. Do you mean it gets the “custom value” from SC? Yes, indeed this means it’s well connected.

To sum up: it works in SonarLint in Connecte Mode, it doesn’t work on SC.

Could you please share the local SonarLint configuration? PROJECT_PATH/.sonarlint/ and verify the rule is enabled in sonaranalyzer-dotnetCSharp.ruleset and share the .sonarlint\sonaranalyzer-dotnet\CSharp\SonarLint.xml with us.

I have given up trying to get this issue solved and am resorting to just Deactivating the rule.

If i go into “Quality Profiles” I can see that the Default C# profile is our one. If i go into that profile I can see that the “Track lack of copyright and license headers” is under deactivated and has an Activate button.

From this is looks to me like the rule is turned off. However in the latest analysis of my feature branch it is still being reported as a code smell.

Why?

I’d like to know more on why it didn’t work, unfortunately you didn’t confirm my understanding was correct in

On the main branch it does not show , however it appears on the feature branch?

tbh I’ve kind of given up. I’d love to know why this doesn’t work but I need to find better way to connect with some support and then get a fast turnaround as I work through the options.

Here is what you were asking me for.

Here is the SonarLint.xml. Note the path is not the same, it is .sonarlint\magicbulletltd_clinicianportal\CSharp.

<?xml version="1.0" encoding="utf-8"?>
<AnalysisInput xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Settings>
    <Setting>
      <Key>sonar.cs.analyzeGeneratedCode</Key>
      <Value>false</Value>
    </Setting>
    <Setting>
      <Key>sonar.cs.file.suffixes</Key>
      <Value>.cs</Value>
    </Setting>
    <Setting>
      <Key>sonar.cs.ignoreHeaderComments</Key>
      <Value>true</Value>
    </Setting>
    <Setting>
      <Key>sonar.cs.roslyn.ignoreIssues</Key>
      <Value>false</Value>
    </Setting>
  </Settings>
  <Rules>
    <Rule>
      <Key>S107</Key>
      <Parameters>
        <Parameter>
          <Key>max</Key>
          <Value>7</Value>
        </Parameter>
      </Parameters>
    </Rule>
    <Rule>
      <Key>S110</Key>
      <Parameters>
        <Parameter>
          <Key>max</Key>
          <Value>5</Value>
        </Parameter>
      </Parameters>
    </Rule>
    <Rule>
      <Key>S1451</Key>
      <Parameters>
        <Parameter>
          <Key>headerFormat</Key>
          <Value>// -{71,}(\n|\r|\r\n)// (\n|\r|\r\n)//\s{5}Copyright (c) Us Ltd. All rights reserved.(\n|\r|\r\n)// &lt;/copyright&gt;(\n|\r|\r\n)// -{71,}</Value>
        </Parameter>
        <Parameter>
          <Key>isRegularExpression</Key>
          <Value>true</Value>
        </Parameter>
      </Parameters>
    </Rule>
    <Rule>
      <Key>S1479</Key>
      <Parameters>
        <Parameter>
          <Key>maximum</Key>
          <Value>30</Value>
        </Parameter>
      </Parameters>
    </Rule>
    <Rule>
      <Key>S2342</Key>
      <Parameters>
        <Parameter>
          <Key>flagsAttributeFormat</Key>
          <Value>^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$</Value>
        </Parameter>
        <Parameter>
          <Key>format</Key>
          <Value>^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$</Value>
        </Parameter>
      </Parameters>
    </Rule>
    <Rule>
      <Key>S2436</Key>
      <Parameters>
        <Parameter>
          <Key>max</Key>
          <Value>2</Value>
        </Parameter>
        <Parameter>
          <Key>maxMethod</Key>
          <Value>3</Value>
        </Parameter>
      </Parameters>
    </Rule>
    <Rule>
      <Key>S3776</Key>
      <Parameters>
        <Parameter>
          <Key>propertyThreshold</Key>
          <Value>3</Value>
        </Parameter>
        <Parameter>
          <Key>threshold</Key>
          <Value>15</Value>
        </Parameter>
      </Parameters>
    </Rule>
  </Rules>
</AnalysisInput>

The rule S1451 does appear in the .ruleset file
<Rule Id="S1451" Action="Warning" />

within the

<Rules AnalyzerId="SonarAnalyzer.CSharp" RuleNamespace="SonarAnalyzer.CSharp">

Element

As it stands I now have the 65+ occurrences of the “Add or up[date the header of this file.” error in the IDE so if we can get it fixed there hopefully we can get it working in sonarcloud.io

Here is an example of one of the headers that i feel should be passing

// --------------------------------------------------------------------------------------------------------------------
// <copyright file="BrowseController.cs" company="Magic Bullet Ltd">
//     Copyright (c) Magic Bullet Ltd. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

I need to apologize on this one. We have Commercial Support who will provide faster turnaround. I’m a software engineer working on the analyzers and sometimes my turnaround can be quite slow.

Thanks a lot for the additional information, I have this on my plate to drive it forward.

We have Commercial Support who will provide faster turnaround. I’m a software engineer working on the analyzers and sometimes my turnaround can be quite slow.

That explains it then. I have also sent a message via your contact form to enquite about Commerical Support.

Would be great to get to the bottom of this one

Thanks