Address minor code style comments

move code out of `converter/index.ts`.

change Converter to be an interface.

remove unused function

remove commented out import

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
alde
2021-04-19 11:51:04 -04:00
committed by Fredrik Adelöw
parent 0e57ec3f91
commit bf02f21eb9
7 changed files with 33 additions and 32 deletions
@@ -0,0 +1,20 @@
/*
* Copyright 2021 Spotify AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { FileEntry } from '../jsoncoverage-types';
export interface Converter {
convert(xml: unknown, scmFiles: Array<string>): Array<FileEntry>;
}
@@ -16,11 +16,11 @@
import { BranchHit, FileEntry } from '../jsoncoverage-types';
import { CoberturaXML, InnerClass, LineHit } from './types';
import { Logger } from 'winston';
import { Converter } from '.';
import { Converter } from './Converter';
export class Cobertura extends Converter {
export class Cobertura implements Converter {
constructor(readonly logger: Logger) {
super(logger);
this.logger = logger;
}
/**
@@ -13,11 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Logger } from 'winston';
import { FileEntry } from '../jsoncoverage-types';
export abstract class Converter {
constructor(readonly logger: Logger) {}
abstract convert(xml: any, scmFiles: Array<string>): Array<FileEntry>;
}
export * from './Converter';
export { Cobertura } from './cobertura';
export { Jacoco } from './jacoco';
@@ -16,7 +16,7 @@
import { BranchHit, FileEntry } from '../jsoncoverage-types';
import { JacocoSourceFile, JacocoXML } from './types';
import { Logger } from 'winston';
import { Converter } from '.';
import { Converter } from './Converter';
type ParsedLine = {
number: number;
@@ -26,9 +26,9 @@ type ParsedLine = {
covered_branches: number;
};
export class Jacoco extends Converter {
export class Jacoco implements Converter {
constructor(readonly logger: Logger) {
super(logger);
this.logger = logger;
}
/**
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import React, { FC, useEffect } from 'react';
import React, { FC } from 'react';
import { useApi } from '@backstage/core-api';
import { useEntity } from '@backstage/plugin-catalog-react';
import { useAsync } from 'react-use';
@@ -31,14 +31,6 @@ type Props = {
coverage: FileCoverage;
};
const getContent = async (value: any) => {
let blob = value;
if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) {
blob = new Blob([value], { type: 'application/octet-stream' });
}
return value;
};
const useStyles = makeStyles(theme => ({
paper: {
margin: 'auto',
@@ -97,10 +89,6 @@ export const FileContent = ({ filename, coverage }: Props) => {
),
);
useEffect(() => {
if (value) getContent(value);
}, [value]);
const classes = useStyles();
if (loading) {
@@ -20,11 +20,10 @@ import highlight from 'highlight.js';
* Given a file extension, repo name, and array of code lines, return a Promise resolving
* to an array of formatted lines with html/css formatting.
*
* @param {String} fileExtension The extension of the source file
* @param {String} repo The name of the code repository
* @param {Array<String>} lines The source code lines
* @param fileExtension The extension of the source file
* @param lines The source code lines
*
* @returns {Promise<Array<String>>} Promise of formatted lines
* @returns Promise of formatted lines
*
* @see http://highlightjs.readthedocs.io/en/latest/api.html#highlight-name-value-ignore-illegals-continuation
*/
-2
View File
@@ -19,5 +19,3 @@ export {
isCodeCoverageAvailable,
isCodeCoverageAvailable as isPluginApplicableToEntity,
} from './components/Router';
// export { createBackendRouter } from './backend/router';