Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix paths/paths-ignore warning that would appear unconditionally #2080

Merged
merged 2 commits into from Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/init.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions lib/init.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/init.test.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/init.test.ts
@@ -0,0 +1,32 @@
import test from "ava";

import { Config } from "./config-utils";
import { printPathFiltersWarning } from "./init";
import { Language } from "./languages";
import { LoggedMessage, getRecordingLogger, setupTests } from "./testing-utils";

setupTests(test);

test("printPathFiltersWarning does not trigger when 'paths' and 'paths-ignore' are undefined", async (t) => {
const messages: LoggedMessage[] = [];
printPathFiltersWarning(
{
languages: [Language.cpp],
originalUserInput: {},
} as Partial<Config> as Config,
getRecordingLogger(messages),
);
t.is(messages.length, 0);
});

test("printPathFiltersWarning does not trigger when 'paths' and 'paths-ignore' are empty", async (t) => {
const messages: LoggedMessage[] = [];
printPathFiltersWarning(
{
languages: [Language.cpp],
originalUserInput: { paths: [], "paths-ignore": [] },
} as Partial<Config> as Config,
getRecordingLogger(messages),
);
t.is(messages.length, 0);
});
9 changes: 6 additions & 3 deletions src/init.ts
Expand Up @@ -127,12 +127,15 @@ export async function runInit(
return await getCombinedTracerConfig(config);
}

function printPathFiltersWarning(config: configUtils.Config, logger: Logger) {
export function printPathFiltersWarning(
config: configUtils.Config,
logger: Logger,
) {
// Index include/exclude/filters only work in javascript/python/ruby.
// If any other languages are detected/configured then show a warning.
if (
(config.originalUserInput.paths?.length !== 0 ||
config.originalUserInput["paths-ignore"]?.length !== 0) &&
(config.originalUserInput.paths?.length ||
config.originalUserInput["paths-ignore"]?.length) &&
!config.languages.every(isScannedLanguage)
) {
logger.warning(
Expand Down