Closed vmasek closed 3 weeks ago
Implemented as custom plugin for customer, along JS Packages plugin equivalent for Poetry package manager.
code-pushup.pylint.plugin.ts
```typescript
import type {
Audit,
AuditOutput,
Group,
Issue,
IssueSeverity,
PluginConfig,
} from "@code-pushup/models";
import {
capitalize,
compareIssueSeverity,
countOccurrences,
executeProcess,
objectToEntries,
pluralizeToken,
truncateIssueMessage,
} from "@code-pushup/utils";
export default async function pylintPlugin(
pattern: string
): Promise
code-pushup.poetry.plugin.ts
```typescript
import type { AuditOutput, Issue, PluginConfig } from '@code-pushup/models';
import { executeProcess, pluralizeToken } from '@code-pushup/utils';
import { diff } from 'semver';
export default function poetryPlugin(): PluginConfig {
return {
slug: 'poetry',
title: 'Poetry',
icon: 'poetry',
audits: [
{
slug: 'vulnerabilities',
title: 'Vulnerabilities',
description: 'Checks for security vulnerabilities in dependencies.',
},
{
slug: 'outdated',
title: 'Outdated versions',
description: 'Checks for outdated packages.',
},
],
runner: () => Promise.all([runAudit(), runOutdated()]),
};
}
async function runAudit(): Promise
code-pushup.config.ts
```typescript import coveragePlugin from '@code-pushup/coverage-plugin'; import type { CoreConfig } from '@code-pushup/models'; import poetryPlugin from './code-pushup.poetry.plugin'; import pylintPlugin from './code-pushup.pylint.plugin'; import 'dotenv/config'; const config: CoreConfig = { plugins: [ await coveragePlugin({ reports: ['../reports/lcov.info'], coverageTypes: ['line'], }), await pylintPlugin('../kw'), poetryPlugin(), ], categories: [ { slug: 'bug-prevention', title: 'Bug prevention', description: "PyLint rules that find **potential bugs** in your code.", refs: [ { type: 'group', plugin: 'pylint', slug: 'error', weight: 5 }, { type: 'group', plugin: 'pylint', slug: 'warning', weight: 1 }, ], }, { slug: 'code-style', title: 'Code style', description: "PyLint rules that promote **good practices** and consistency in your code.", refs: [ { type: 'group', plugin: 'pylint', slug: 'refactor', weight: 1 }, { type: 'group', plugin: 'pylint', slug: 'convention', weight: 1 }, { type: 'group', plugin: 'pylint', slug: 'info', weight: 0 }, ], }, { slug: 'coverage', title: 'Code coverage', description: 'How many lines of code are **covered by tests** with pytest.', refs: [ { type: 'audit', plugin: 'coverage', slug: 'line-coverage', weight: 1 }, ], }, { slug: 'security', title: 'Security', description: "Finds known **vulnerabilities** in Poetry packages.", refs: [ { type: 'audit', plugin: 'poetry', slug: 'vulnerabilities', weight: 1 }, ], }, { slug: 'updates', title: 'Updates', description: "Finds **outdated** Poetry packages.", refs: [{ type: 'audit', plugin: 'poetry', slug: 'outdated', weight: 1 }], }, ], ...(process.env.CP_API_KEY && { upload: { server: 'https://api.codepushup.skypicker.com/graphql', apiKey: process.env.CP_API_KEY, organization: 'kiwi', project: 'autobooking-backbone', }, }), }; export default config; ```
@vmasek I'd suggest closing this research issue in favour of creating new issues to build the official Python plugins based on this prototype.
User story
PyLint has set of rules to be found here that offer static analysis checks for python code.
They are sorted into severity groups but they are missing any categorization or labeling. We could use manual sorting or script to get them into desired categories (
code style
|bug prevention
)TODO:
--list-msgs-enabled
option to see which rules are included in static analysis