• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

badges / shields / 16386279195

15 Jul 2025 08:07PM UTC coverage: 97.949% (-0.04%) from 97.987%
16386279195

push

github

web-flow
chore(deps-dev): bump neostandard from 0.12.1 to 0.12.2 (#11199)

Bumps [neostandard](https://github.com/neostandard/neostandard) from 0.12.1 to 0.12.2.
- [Release notes](https://github.com/neostandard/neostandard/releases)
- [Changelog](https://github.com/neostandard/neostandard/blob/main/CHANGELOG.md)
- [Commits](https://github.com/neostandard/neostandard/compare/v0.12.1...v0.12.2)

---
updated-dependencies:
- dependency-name: neostandard
  dependency-version: 0.12.2
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

5913 of 6185 branches covered (95.6%)

49870 of 50914 relevant lines covered (97.95%)

131.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.47
/services/codeclimate/codeclimate-analysis.service.js
1
import Joi from 'joi'
3✔
2
import { colorScale, letterScore } from '../color-formatters.js'
3✔
3
import { nonNegativeInteger } from '../validators.js'
3✔
4
import { BaseJsonService, NotFound, pathParams } from '../index.js'
3✔
5
import { isLetterGrade, fetchRepo } from './codeclimate-common.js'
3✔
6

3✔
7
const schema = Joi.object({
3✔
8
  data: Joi.object({
3✔
9
    meta: Joi.object({
3✔
10
      issues_count: nonNegativeInteger,
3✔
11
    }).required(),
3✔
12
    attributes: Joi.object({
3✔
13
      ratings: Joi.array()
3✔
14
        .items(
3✔
15
          Joi.object({
3✔
16
            letter: isLetterGrade,
3✔
17
            measure: Joi.object({
3✔
18
              value: Joi.number().required(),
3✔
19
            }).required(),
3✔
20
          }),
3✔
21
        )
3✔
22
        .length(1)
3✔
23
        .required(),
3✔
24
    }).required(),
3✔
25
  }).required(),
3✔
26
}).required()
3✔
27

3✔
28
const maintainabilityColorScale = colorScale(
3✔
29
  [50, 80, 90, 95],
3✔
30
  ['red', 'yellow', 'yellowgreen', 'green', 'brightgreen'],
3✔
31
)
3✔
32
const techDebtColorScale = colorScale(
3✔
33
  [5, 10, 20, 50],
3✔
34
  ['brightgreen', 'green', 'yellowgreen', 'yellow', 'red'],
3✔
35
)
3✔
36
const issueColorScale = colorScale(
3✔
37
  [1, 5, 10, 20],
3✔
38
  ['brightgreen', 'green', 'yellowgreen', 'yellow', 'red'],
3✔
39
)
3✔
40

3✔
41
const variantMap = {
3✔
42
  maintainability: {
3✔
43
    transform: data => ({
3✔
44
      maintainabilityLetter: data.attributes.ratings[0].letter,
×
45
    }),
3✔
46
    render: ({ maintainabilityLetter }) => ({
3✔
47
      label: 'maintainability',
×
48
      message: maintainabilityLetter,
×
49
      color: letterScore(maintainabilityLetter),
×
50
    }),
3✔
51
  },
3✔
52
  'maintainability-percentage': {
3✔
53
    transform: data => ({
3✔
54
      techDebtPercentage: data.attributes.ratings[0].measure.value,
×
55
    }),
3✔
56
    render: ({ techDebtPercentage }) => {
3✔
57
      // maintainability = 100 - technical debt.
×
58
      const maintainabilityPercentage = 100 - techDebtPercentage
×
59
      return {
×
60
        label: 'maintainability',
×
61
        message: `${maintainabilityPercentage.toFixed(0)}%`,
×
62
        color: maintainabilityColorScale(maintainabilityPercentage),
×
63
      }
×
64
    },
3✔
65
  },
3✔
66
  'tech-debt': {
3✔
67
    transform: data => ({
3✔
68
      techDebtPercentage: data.attributes.ratings[0].measure.value,
×
69
    }),
3✔
70
    render: ({ techDebtPercentage }) => ({
3✔
71
      label: 'technical debt',
×
72
      message: `${techDebtPercentage.toFixed(0)}%`,
×
73
      color: techDebtColorScale(techDebtPercentage),
×
74
    }),
3✔
75
  },
3✔
76
  issues: {
3✔
77
    transform: data => ({
3✔
78
      issueCount: data.meta.issues_count,
1✔
79
    }),
3✔
80
    render: ({ issueCount }) => ({
3✔
81
      label: 'issues',
1✔
82
      message: `${issueCount}`,
1✔
83
      color: issueColorScale(issueCount),
1✔
84
    }),
3✔
85
  },
3✔
86
}
3✔
87

3✔
88
export default class CodeclimateAnalysis extends BaseJsonService {
3✔
89
  static category = 'analysis'
3✔
90
  static route = {
3✔
91
    base: 'codeclimate',
3✔
92
    pattern:
3✔
93
      ':variant(maintainability|maintainability-percentage|tech-debt|issues)/:user/:repo',
3✔
94
  }
3✔
95

3✔
96
  static openApi = {
3✔
97
    '/codeclimate/{variant}/{user}/{repo}': {
3✔
98
      get: {
3✔
99
        summary: 'Code Climate maintainability',
3✔
100
        parameters: pathParams(
3✔
101
          {
3✔
102
            name: 'variant',
3✔
103
            example: 'maintainability',
3✔
104
            schema: {
3✔
105
              type: 'string',
3✔
106
              enum: ['maintainability', 'maintainability-percentage'],
3✔
107
            },
3✔
108
          },
3✔
109
          { name: 'user', example: 'tensorflow' },
3✔
110
          { name: 'repo', example: 'models' },
3✔
111
        ),
3✔
112
      },
3✔
113
    },
3✔
114
    '/codeclimate/tech-debt/{user}/{repo}': {
3✔
115
      get: {
3✔
116
        summary: 'Code Climate technical debt',
3✔
117
        parameters: pathParams(
3✔
118
          { name: 'user', example: 'tensorflow' },
3✔
119
          { name: 'repo', example: 'models' },
3✔
120
        ),
3✔
121
      },
3✔
122
    },
3✔
123
    '/codeclimate/issues/{user}/{repo}': {
3✔
124
      get: {
3✔
125
        summary: 'Code Climate issues',
3✔
126
        parameters: pathParams(
3✔
127
          { name: 'user', example: 'tensorflow' },
3✔
128
          { name: 'repo', example: 'models' },
3✔
129
        ),
3✔
130
      },
3✔
131
    },
3✔
132
  }
3✔
133

3✔
134
  static render({ variant, ...props }) {
3✔
135
    const { render } = variantMap[variant]
1✔
136

1✔
137
    return render(props)
1✔
138
  }
1✔
139

3✔
140
  async fetch({ user, repo }) {
3✔
141
    const repoInfos = await fetchRepo(this, { user, repo })
9✔
142
    const repoInfosWithSnapshot = repoInfos.filter(
1✔
143
      repoInfo => repoInfo.relationships.latest_default_branch_snapshot.data,
1✔
144
    )
1✔
145
    if (repoInfosWithSnapshot.length === 0) {
9!
146
      throw new NotFound({ prettyMessage: 'snapshot not found' })
×
147
    }
×
148
    const {
1✔
149
      id: repoId,
1✔
150
      relationships: {
1✔
151
        latest_default_branch_snapshot: { data: snapshotInfo },
1✔
152
      },
1✔
153
    } = repoInfosWithSnapshot[0]
1✔
154
    const { data } = await this._requestJson({
1✔
155
      schema,
1✔
156
      url: `https://api.codeclimate.com/v1/repos/${repoId}/snapshots/${snapshotInfo.id}`,
1✔
157
    })
1✔
158
    return data
1✔
159
  }
9✔
160

3✔
161
  async handle({ variant, user, repo }) {
3✔
162
    const { transform } = variantMap[variant]
9✔
163

9✔
164
    const data = await this.fetch({ user, repo })
9✔
165
    const props = transform(data)
1✔
166
    return this.constructor.render({
1✔
167
      variant,
1✔
168
      ...props,
1✔
169
    })
1✔
170
  }
9✔
171
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc