Skip to content

Conversation

@AGr-AlexandrGrigoryev
Copy link

@AGr-AlexandrGrigoryev AGr-AlexandrGrigoryev commented Feb 27, 2023

Added check of duplicated keys in the Spreadsheet before writing to the file. If duplicate keys exist, show the error with duplicated keys.

Checklist

  • Added tests (if applicable)

@github-actions
Copy link

@AGr-AlexandrGrigoryev your pull request is missing a changelog!

@AGr-AlexandrGrigoryev AGr-AlexandrGrigoryev changed the title ✨ added check for duplicate keys -#78843 ✨ added check for duplicated keys -#78843 Feb 27, 2023
CHANGELOG.md Outdated
## master

### Added
- Add check for duplicated keys in Spreadsheet ([#38](https://github.com/AckeeCZ/ACKLocalization/pull/38), kudos to @AGr-AlexandrGrigoryev)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please rename it to "duplicate keys" 🤓

guard rows.count > 0 else { return }

try checkDuplicateKeys(form: rows)
try checkDuplicatedKeys(form: rows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"checkDuplicateKeys" was correct

/// Check if given `rows` have a duplicated keys
public func checkDuplicatedKeys(form rows: [LocRow]) throws {
let keys = rows.map { $0.key }
let uniqueKeys = Set(rows.map { $0.key })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 let uniqueKeys = Set(keys)

XCTAssertEqual(#""pos_arg_key" = "%1$@ people will arrive in %2$@ minutes";"#, locRow.localizableRow)
}

func testForDuplicatedKeys() throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please move it to the ACKLocalizationTests, this has nothing to do with LocRow. Also add test for success path (one duplicate keys)

@github-actions
Copy link

This PR has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 30, 2023
@github-actions github-actions bot closed this Apr 5, 2023
@LukasHromadnik LukasHromadnik reopened this Apr 6, 2023
@LukasHromadnik LukasHromadnik merged commit 5bd1b53 into master Apr 6, 2023
@LukasHromadnik LukasHromadnik deleted the feature/duplicateKeys-#78843 branch April 6, 2023 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants