MCPcopy Create free account
hub / github.com/code-pushup/cli / formatGitHubLink

Function formatGitHubLink

packages/utils/src/lib/reports/formatting.ts:143–160  ·  view source on GitHub ↗
(
  file: string,
  position: SourceFileLocation['position'],
)

Source from the content-addressed store, hash-verified

141}
142
143export function formatGitHubLink(
144 file: string,
145 position: SourceFileLocation['position'],
146): string {
147 const baseUrl = getGitHubBaseUrl();
148 if (!position) {
149 return `${baseUrl}/${file}`;
150 }
151 const { startLine, endLine, startColumn, endColumn } = position;
152 const start = startColumn ? `L${startLine}C${startColumn}` : `L${startLine}`;
153 const end = endLine
154 ? endColumn
155 ? `L${endLine}C${endColumn}`
156 : `L${endLine}`
157 : '';
158 const lineRange = end && start !== end ? `${start}-${end}` : start;
159 return `${baseUrl}/${file}#${lineRange}`;
160}
161
162export function formatGitLabLink(
163 file: string,

Callers 2

formatFileLinkFunction · 0.85

Calls 1

getGitHubBaseUrlFunction · 0.85

Tested by

no test coverage detected