SonarQube Exclude a directory

前端 未结 13 812
失恋的感觉
失恋的感觉 2020-12-23 02:43

I am trying to exclude a directory from being analyzed by Sonar. I have the following properties defined in my sonar-project.properties file:

so         


        
相关标签:
13条回答
  • 2020-12-23 03:11

    Easiest way is to go to the server URL after starting the server(localhost:8080) then login as admin,Go to settings>Exclusions> Source File Exclusions- Add your packages here. Restart the server.

    0 讨论(0)
  • 2020-12-23 03:12

    I'm able to exclude multiple directories using the below config (comma separated folder paths):

    sonar.exclusions=system/**, test/**, application/third_party/**, application/logs/**
    

    And while running the sonar runner I got the following in the log:

    Excluded sources: 
      system/**
      test/**
      application/third_party/**
      application/logs/**
    
    0 讨论(0)
  • 2020-12-23 03:13

    This will work for your case:

    sonar.exclusions=**/src/java/dig/ ** , **/src/java/test/dig/ **
    
    0 讨论(0)
  • 2020-12-23 03:13

    If we want to skip the entire folder following can be used:

    sonar.exclusions=folderName/**/*
    

    And if we have only one particular file just give the complete path.

    All the folder which needs to be exclude and be appended here.

    0 讨论(0)
  • 2020-12-23 03:15

    If you're an Azure DevOps user looking for both where and how to exclude files and folders, here ya go:

    1. Edit your pipeline
    2. Make sure you have the "Prepare analysis on SonarQube" task added. You'll need to look elsewhere if you need help configuring this. Suggestion: Use the UI pipeline editor vs the yaml editor if you are missing the manage link. At present, there is no way to convert to UI from yaml. Just recreate the pipeline. If using git, you can delete the yaml from the root of your repo.
    3. Under the 'Advanced' section of the "Prepare analysis on SonarQube" task, you can add exclusions. See advice given by others for specific exclusion formats.

    Example:

    # Additional properties that will be passed to the scanner, 
    # Put one key=value per line, example:
    # sonar.exclusions=**/*.bin
    sonar.exclusions=MyProjectName/MyWebContentFolder/**
    

    Note: If you're not sure on the path, you can go into sonarqube, view your project, look at all or new 'Code Smells' and the path you need is listed above each grouping of issues. You can grab the full path to a file or use wilds like these examples:

    • MyProjectName/MyCodeFile.cs
    • MyProjectName/**

    If you don't have the 'Run Code Analysis' task added, do that and place it somewhere after the 'Build solution **/*.sln' task.

    Save and Queue and then check out your sonarqube server to see if the exclusions worked.

    0 讨论(0)
  • 2020-12-23 03:19

    Add comma separated folder paths sonar.exclusions=**/abc/**,**/def/**

    This worked in an angular project

    0 讨论(0)
提交回复
热议问题