You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileStructure.java 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. package org.sonar.scanner.protocol.output;
  21. import java.io.File;
  22. import javax.annotation.concurrent.Immutable;
  23. /**
  24. * Structure of files in the zipped report
  25. */
  26. @Immutable
  27. public class FileStructure {
  28. public enum Domain {
  29. ISSUES("issues-", Domain.PB),
  30. EXTERNAL_ISSUES("external-issues-", Domain.PB),
  31. COMPONENT("component-", Domain.PB),
  32. MEASURES("measures-", Domain.PB),
  33. DUPLICATIONS("duplications-", Domain.PB),
  34. CPD_TEXT_BLOCKS("cpd-text-block-", Domain.PB),
  35. SYNTAX_HIGHLIGHTINGS("syntax-highlightings-", Domain.PB),
  36. CHANGESETS("changesets-", Domain.PB),
  37. SYMBOLS("symbols-", Domain.PB),
  38. COVERAGES("coverages-", Domain.PB),
  39. SOURCE("source-", ".txt"),
  40. SGNIFICANT_CODE("sgnificant-code-", Domain.PB),
  41. CHANGED_LINES("changed-lines-", Domain.PB);
  42. private static final String PB = ".pb";
  43. private final String filePrefix;
  44. private final String fileSuffix;
  45. Domain(String filePrefix, String fileSuffix) {
  46. this.filePrefix = filePrefix;
  47. this.fileSuffix = fileSuffix;
  48. }
  49. }
  50. private final File dir;
  51. public FileStructure(File dir) {
  52. if (!dir.exists() || !dir.isDirectory()) {
  53. throw new IllegalArgumentException("Directory of analysis report does not exist: " + dir);
  54. }
  55. this.dir = dir;
  56. }
  57. public File metadataFile() {
  58. return new File(dir, "metadata.pb");
  59. }
  60. public File analysisLog() {
  61. return new File(dir, "analysis.log");
  62. }
  63. public File activeRules() {
  64. return new File(dir, "activerules.pb");
  65. }
  66. public File adHocRules() {
  67. return new File(dir, "adhocrules.pb");
  68. }
  69. public File fileFor(Domain domain, int componentRef) {
  70. return new File(dir, domain.filePrefix + componentRef + domain.fileSuffix);
  71. }
  72. public File contextProperties() {
  73. return new File(dir, "context-props.pb");
  74. }
  75. public File analysisWarnings() {
  76. return new File(dir, "analysis-warnings.pb");
  77. }
  78. public File root() {
  79. return dir;
  80. }
  81. }