|
- module SonarService
- def build_sonar_content(owner,project_id,lang_keys)
- lang_map = {
- 'Java' => :java,
- 'Python' => :python,
- 'JavaScript' => :js,
- 'TypeScript' => :ts,
- 'C++' => :cpp,
- 'C' => :cpp
- }
-
- detected_langs = lang_keys.map { |l| lang_map[l] }.compact.to_set
-
- lines = []
- lines << "sonar.projectKey=#{owner}-#{project_id}"
- lines << "sonar.projectVersion=1.0"
- lines << "sonar.sourceEncoding=UTF-8"
- lines << "sonar.sources=."
- lines << "sonar.exclusions=**/test/**,**/tests/**,**/vendor/**,**/node_modules/**,**/__pycache__/**"
-
- if detected_langs.include?(:java)
- lines << "sonar.java.binaries="
- end
-
- if detected_langs.include?(:js)
- lines << "sonar.javascript.lcov.reportPaths=coverage/lcov.info"
- end
-
- if detected_langs.include?(:ts)
- lines << "sonar.typescript.tsconfigPath=tsconfig.json"
- end
-
- if detected_langs.include?(:python)
- lines << "sonar.python.coverage.reportPaths=coverage.xml"
- end
-
- if detected_langs.include?(:cpp)
- lines << "sonar.cxx.file.suffixes=.cpp,.c,.cc,.h,.hpp,.hh"
- lines << "sonar.cxx.errorRecoveryEnabled=true"
- end
-
- lines.join("\n")
- end
- end
|