All files / ee/app/assets/javascripts/codequality_report codequality_report.vue

94.12% Statements 16/17
83.33% Branches 5/6
100% Functions 5/5
94.12% Lines 16/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86  1x 1x 1x 1x 1x 1x                         6x     6x 6x   6x 3x 3x 3x                       6x                 12x                         24x                                              
<script>
import { mapActions, mapState, mapGetters } from 'vuex';
import { componentNames } from 'ee/reports/components/issue_body';
import reportsMixin from 'ee/vue_shared/security_reports/mixins/reports_mixin';
import { n__, s__, sprintf } from '~/locale';
import ReportSection from '~/reports/components/report_section.vue';
import PaginationLinks from '~/vue_shared/components/pagination_links.vue';
 
export default {
  components: {
    ReportSection,
    PaginationLinks,
  },
  mixins: [reportsMixin],
  componentNames,
  computed: {
    ...mapState(['isLoadingCodequality', 'loadingCodequalityFailed', 'pageInfo']),
    ...mapGetters(['codequalityIssues', 'codequalityIssueTotal']),
    hasCodequalityIssues() {
      return this.codequalityIssueTotal > 0;
    },
    codequalityText() {
      const text = [];
      const { codequalityIssueTotal } = this;
 
      if (codequalityIssueTotal === 0) {
        return s__('ciReport|No code quality issues found');
E      } else if (codequalityIssueTotal > 0) {
        return sprintf(s__('ciReport|Found %{issuesWithCount}'), {
          issuesWithCount: n__(
            '%d code quality issue',
            '%d code quality issues',
            codequalityIssueTotal,
          ),
        });
      }
 
      return text.join('');
    },
    codequalityStatus() {
      return this.checkReportStatus(this.isLoadingCodequality, this.loadingCodequalityFailed);
    },
  },
  i18n: {
    subHeading: s__('ciReport|This report contains all Code Quality issues in the source branch.'),
  },
  methods: {
    ...mapActions(['setPage']),
    translateText(type) {
      return {
        error: sprintf(s__('ciReport|Failed to load %{reportName} report'), {
          reportName: type,
        }),
        loading: sprintf(s__('ciReport|Loading %{reportName} report'), {
          reportName: type,
        }),
      };
    },
  },
};
</script>
 
<template>
  <div>
    <report-section
      always-open
      :status="codequalityStatus"
      :loading-text="translateText('Code Quality').loading"
      :error-text="translateText('Code Quality').error"
      :success-text="codequalityText"
      :unresolved-issues="codequalityIssues"
      :resolved-issues="[]"
      :has-issues="hasCodequalityIssues"
      :component="$options.componentNames.CodequalityIssueBody"
      class="codequality-report"
    >
      <template v-if="hasCodequalityIssues" #sub-heading>{{ $options.i18n.subHeading }}</template>
    </report-section>
    <pagination-links
      :change="setPage"
      :page-info="pageInfo"
      class="d-flex justify-content-center gl-mt-3"
    />
  </div>
</template>