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

Unable to run BartyCrouch when project includes other eval such as LineEnding of the CSVImporter library #184

Open
yannisps opened this issue Apr 27, 2020 · 1 comment
Labels

Comments

@yannisps
Copy link

Expected Behaviour

BartyCrouch update command fails to update the sources and add into translated strings.

caseToLangCode to evaluate to: ["italian": "it", "chineseSimplified": "zh-Hans", "portuguese": "pt-BR", "malay": "ms", "korean": "ko", "chineseTraditional": "zh-Hant", "turkish": "tr", "german": "de", "arabic": "ar", "japanese": "ja", "french": "fr", "english": "en", "spanish": "es", "hindi": "hi", "russian": "ru"]
i.e. the contents of the enum SupportedLanguage

Actual Behavior

caseToLangCode evaluates to:
["carriageReturnLineFeed": "\\r\\n", "unknown": "", "newLine": "\\n", "carriageReturn": "\\r"]
which is the enum found in the CSVImporter.swift
/// An enum to represent the possible line endings of CSV files. public enum LineEnding: String { case newLine = "\n" case carriageReturn = "\r" case carriageReturnLineFeed = "\r\n" case unknown = "" }

As a result no languages are found and consequently no updates take place.

Steps to Reproduce the Problem

  1. Include the Flinesoft CSVImporter or any enum in the Demo project.
    Following a detailed investigation I discovered the following by adding this line in the Su[pportedLanguagesReader.swift:
    print("Visiting SupportedLanguagesReader (enumDeclaration.parent?.as(CodeBlockItemSyntax.self) != nil), (enumDeclaration.identifier.text)" , level: .info)

The first test is aways TRUE and the || if enumDeclaration.parent?.as(CodeBlockItemSyntax.self) != nil && enumDeclaration.identifier.text == "SupportedLanguage" always evaluates our TRUE so the code adds any enum it finds in the code as Language Settings.
Furthermore, the second test never evaluated to TRUE as the SupportedLanguage is en eval inside BartyCrouch recommended syntax.

My workaround is to make the SupportedLanguage an independent eval from the BartyCrouch eval and change the || of the SupportedLanguagesReader.swift to &&.
i.e. from:

enum BartyCrouch {
    enum SupportedLanguage: String {
        case arabic = "ar"
...

to:

enum SupportedLanguage: String {
       // TODO: remove unsupported languages from the following cases list & add any missing languages
        case arabic = "ar"
...
}
enum BartyCrouch {
...

Specifications

  • Version: 4.2.0
@yannisps yannisps added the bug label Apr 27, 2020
@Jeehut
Copy link
Member

Jeehut commented Apr 28, 2020

@yannisps Thank you for reporting this bug. It seems to me like you already investigated the code, so I guess you are closer to a solution then I would be when I started to understand the problem. So would you mind taking the next step and fixing this yourself? I'd happily review and merge your PR. In the best case, you would first write a test that fails at the moment, then implement your fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants