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

Implement .rultor.yml Validation, Remove Invalid Puzzle #1032

Open
original-brownbear opened this issue Feb 29, 2016 · 7 comments
Open

Implement .rultor.yml Validation, Remove Invalid Puzzle #1032

original-brownbear opened this issue Feb 29, 2016 · 7 comments
Labels

Comments

@original-brownbear
Copy link
Contributor

Problem

We currently do not really validate the .rultor.yml file. This was a feature desired in #570 and led to the addition of the validation snippet in this code ( and some now ignored tests ) in this PR:

    /**
     * Get .rultor.yml file.
     * @return Its content
     * @throws IOException If fails
     */
    private String yml() throws IOException {
        final String yml;
        if (this.repo.contents()
            .exists(GithubProfile.FILE, this.branch)) {
            yml = new String(
                new Content.Smart(
                    this.repo.contents().get(GithubProfile.FILE)
                ).decoded(),
                CharEncoding.UTF_8
            );
        } else {
            yml = "";
        }
        final List<String> msg = this.validate(yml);
        if (!msg.isEmpty()) {
            throw new Profile.ConfigException(
                String.format(
                    "`%s` is not valid according to schema:\n``%s``",
                    GithubProfile.FILE,
                    Joiner.on('\n').join(msg)
                )
            );
        }
        return yml;
    }

    /**
     * Validate rultor config YAML according to schema.
     * @param yml Rultor YAML config
     * @return Validation result message, empty list means validation succeeded.
     * @todo #570:30min Implement validation using Kwalify library in separate
     *  class called ValidYaml, move this method to that class and move tests
     *  from GitHubProfileValidationTest to ValidYamlTest. Remember about
     *  removing PMD suppress below.
     */
    @SuppressWarnings("PMD.UnusedFormalParameter")
    private List<String> validate(final String yml) {
        return Collections.emptyList();
    }

There are a few problems here now:

  • We still don't have YAML validation :)
  • Using the Kwalify library is not a valid approach anymore looking the official site for it, it is clear the library is not maintained anymore.
  • "%sis not valid according to schema:\n``%s``" should be reworded. "according to schema" (what schema?) and then listing the issues after is neither correct English nor user friendly.

Expected Solution

A solution to this issue needs to:

  • Move the validation to com.rultor.profiles.GithubProfile#read or the com.rultor.profiles.YamlXML#get to com.rultor.profiles.GithubProfile#yml so that it actually runs after the yaml has been parsed, not on the string. ( the current puzzle being solved directly would otherwise entail parsing the YAML twice!)
    • No need to add a new parser library either we already have this one in the pom.xml:
        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.16</version>
        </dependency>
@original-brownbear
Copy link
Contributor Author

@alex-palevsky this is a bug.

@alex-palevsky
Copy link
Contributor

@alex-palevsky this is a bug.

@original-brownbear tag bug added to this issue

@alex-palevsky
Copy link
Contributor

@original-brownbear since there is no milestone yet I set it to "2.0"

@alex-palevsky alex-palevsky added this to the 2.0 milestone Feb 29, 2016
@alex-palevsky
Copy link
Contributor

@original-brownbear thanks for the report, I topped your acc for 30 mins, payment ID AP-0UT81441V1306624N

@original-brownbear
Copy link
Contributor Author

@alex-palevsky this is postponed.

@alex-palevsky
Copy link
Contributor

@alex-palevsky this is postponed.

@original-brownbear OK, I put "postponed" label here

@alex-palevsky
Copy link
Contributor

@alex-palevsky this is postponed.

@original-brownbear I will try to find someone else

@yegor256 yegor256 removed this from the 2.0 milestone Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants