Skip to content

Commit

Permalink
fix(lint): Use correct line number (#45)
Browse files Browse the repository at this point in the history
* correct line number

* add changelog entry
  • Loading branch information
MalteHerrmann committed Jun 30, 2024
1 parent 401d943 commit 8a25276
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ This changelog was created using the `clu` binary
-->
# Changelog

## [v1.1.2](https://github.com/MalteHerrmann/changelog-utils/releases/tag/v1.1.2) - 2024-06-30

### Bug Fixes

- (lint) [#45](https://github.com/MalteHerrmann/changelog-utils/pull/45) Use correct line number.

## [v1.1.1](https://github.com/MalteHerrmann/changelog-utils/releases/tag/v1.1.1) - 2024-06-30

### Bug Fixes
Expand Down
4 changes: 3 additions & 1 deletion src/changelog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ pub fn parse_changelog(config: Config, file_path: &Path) -> Result<Changelog, Ch
}

/// Used for formatting the problem statements in the changelog.
///
/// NOTE: The line ID will be incremented by one based on the loop enumeration where it is used.
fn add_to_problems(problems: &mut Vec<String>, fp: &Path, line: usize, problem: impl Into<String>) {
problems.push(format!("{}:{}: {}", fp.to_string_lossy(), line, problem.into()))
problems.push(format!("{}:{}: {}", fp.to_string_lossy(), line+1, problem.into()))
}

#[cfg(test)]
Expand Down
20 changes: 10 additions & 10 deletions tests/lint_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ fn it_should_pass_for_incorrect_changelogs_that_has_no_critical_flaws() {
assert_eq!(
changelog.problems,
vec![
"tests/testdata/changelog_fail.md:10: PR link is not matching PR number 1948: 'https://github.com/evmos/evmos/pull/1949'",
"tests/testdata/changelog_fail.md:19: There should be no backslash in front of the # in the PR link",
"tests/testdata/changelog_fail.md:20: 'ABI' should be used instead of 'ABi'",
"tests/testdata/changelog_fail.md:24: PR description should end with a dot: 'Fixed the problem `gas_used` is 0'",
"tests/testdata/changelog_fail.md:26: 'Invalid Category' is not a valid change type",
"tests/testdata/changelog_fail.md:30: duplicate change type in release Unreleased: Bug Fixes",
"tests/testdata/changelog_fail.md:39: duplicate PR: #1801",
"tests/testdata/changelog_fail.md:41: duplicate release: v15.0.0",
"tests/testdata/changelog_fail.md:45: duplicate PR: #1862",
"tests/testdata/changelog_fail.md:46: invalid entry: - malformed entry in changelog",
"tests/testdata/changelog_fail.md:11: PR link is not matching PR number 1948: 'https://github.com/evmos/evmos/pull/1949'",
"tests/testdata/changelog_fail.md:20: There should be no backslash in front of the # in the PR link",
"tests/testdata/changelog_fail.md:21: 'ABI' should be used instead of 'ABi'",
"tests/testdata/changelog_fail.md:25: PR description should end with a dot: 'Fixed the problem `gas_used` is 0'",
"tests/testdata/changelog_fail.md:27: 'Invalid Category' is not a valid change type",
"tests/testdata/changelog_fail.md:31: duplicate change type in release Unreleased: Bug Fixes",
"tests/testdata/changelog_fail.md:40: duplicate PR: #1801",
"tests/testdata/changelog_fail.md:42: duplicate release: v15.0.0",
"tests/testdata/changelog_fail.md:46: duplicate PR: #1862",
"tests/testdata/changelog_fail.md:47: invalid entry: - malformed entry in changelog",
]
);
}
Expand Down

0 comments on commit 8a25276

Please sign in to comment.