diff -Nru io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/debian/changelog io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/debian/changelog --- io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/debian/changelog 2018-02-13 20:37:47.000000000 +0000 +++ io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/debian/changelog 2018-02-15 14:33:07.000000000 +0000 @@ -1,8 +1,8 @@ -io.elementary.vala-lint (0.1+r20+pkg4~daily~ubuntu18.04.1) bionic; urgency=low +io.elementary.vala-lint (0.1+r21+pkg4~daily~ubuntu18.04.1) bionic; urgency=low * Auto build. - -- Launchpad Package Builder Tue, 13 Feb 2018 20:37:47 +0000 + -- Launchpad Package Builder Thu, 15 Feb 2018 14:33:07 +0000 io.elementary.vala-lint (0.1) bionic; urgency=medium diff -Nru io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/debian/git-build-recipe.manifest io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/debian/git-build-recipe.manifest --- io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/debian/git-build-recipe.manifest 2018-02-13 20:37:47.000000000 +0000 +++ io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/debian/git-build-recipe.manifest 2018-02-15 14:33:07.000000000 +0000 @@ -1,3 +1,3 @@ -# git-build-recipe format 0.4 deb-version {debupstream}+r20+pkg4~daily -lp:~elementary-apps/elementaryos/+git/vala-lint git-commit:ce79eee5fb146f022cc115c58d6e4f50dfe4404f +# git-build-recipe format 0.4 deb-version {debupstream}+r21+pkg4~daily +lp:~elementary-apps/elementaryos/+git/vala-lint git-commit:fc09f7670afc17142bf12f103b97e6252b3a1b77 nest-part packaging lp:~elementary-apps/elementaryos/+git/vala-lint debian debian git-commit:5735a3a45256b440a1325ececc4f11b4b32dbaae diff -Nru io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/README.md io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/README.md --- io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/README.md 2018-02-13 20:37:46.000000000 +0000 +++ io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/README.md 2018-02-15 14:33:06.000000000 +0000 @@ -12,33 +12,25 @@ gio-2.0 gee-0.8 valac - + Run meson build to configure the build environment. Change to the build directory and run ninja test to build and run automated tests meson build --prefix=/usr cd build ninja test - + To install, use ninja install, then execute with `io.elementary.vala-lint` sudo ninja install io.elementary.vala-lint ## Usage -You can use the command-line tool to scan files or include the library into your own projects to scan single lines or whole files easily. +You can use the command-line tool to scan files or include the library into your own projects to scan single lines or whole files easily. By default, the command-line tool uses [globs](https://en.wikipedia.org/wiki/Glob_%28programming%29) to match files. For example, by + + io.elementary.vala-lint *.vala + +you can lint every file in the current directory. Using the directory `d`-flag, you can lint every Vala file in a given directory and all subdirectories by + + io.elementary.vala-lint -d ../my-project -### Command-Line Example -Scan the vala-lint repository itself: `io.elementary.vala-lint ../**/*.vala` -Scan every vala file in the current directory: `io.elementary.vala-lint $(find . -type f -name "*.vala")` - -### Command-Line Parameters -``` -Usage: - io.elementary.vala-lint [OPTION...] - vala-lint - -Help Options: - -h, --help Show help options - -Application Options: - -v, --version Display version -``` +For all options, type `io.elementary.vala-lint -h`. diff -Nru io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/src/Application.vala io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/src/Application.vala --- io.elementary.vala-lint-0.1+r20+pkg4~daily~ubuntu18.04.1/src/Application.vala 2018-02-13 20:37:46.000000000 +0000 +++ io.elementary.vala-lint-0.1+r21+pkg4~daily~ubuntu18.04.1/src/Application.vala 2018-02-15 14:33:06.000000000 +0000 @@ -21,9 +21,14 @@ public class ValaLint.Application : GLib.Application { private static bool print_version = false; + private static string lint_directory; + + private Linter linter; + private ApplicationCommandLine application_command_line; private const OptionEntry[] options = { { "version", 'v', 0, OptionArg.NONE, ref print_version, "Display version number", null }, + { "directory", 'd', 0, OptionArg.STRING, ref lint_directory, "Lint all Vala files in the given directory." }, { null } }; @@ -69,8 +74,15 @@ return 0; } + linter = new Linter (); + this.application_command_line = command_line; + try { - do_checks (command_line, args[1:args.length]); + if (lint_directory != null) { + check_directory (File.new_for_path (lint_directory)); + } else { + check_globs (command_line, args[1:args.length]); + } } catch (Error e) { command_line.print (_("Error: %s") + "\n", e.message); } @@ -78,9 +90,7 @@ return 0; } - private void do_checks (ApplicationCommandLine command_line, string[] patterns) throws Error, IOError { - var linter = new Linter (); - + void check_globs (ApplicationCommandLine command_line, string[] patterns) throws Error, IOError { foreach (string pattern in patterns) { var matcher = Posix.Glob (); @@ -98,19 +108,43 @@ continue; } - Gee.ArrayList mistakes = linter.run_checks_for_file (file); - - if (!mistakes.is_empty) { - command_line.print ("\x001b[1m\x001b[4m" + "%s" + "\x001b[0m\n", path); + check_file (file); + } + } + } - foreach (FormatMistake mistake in mistakes) { - command_line.print ("\x001b[0m%5i:%-3i \x001b[1m%-40s \x001b[0m%s\n", - mistake.line_index, - mistake.char_index, - mistake.mistake, - mistake.check.get_title ()); - } + void check_directory (File dir) throws Error, IOError { + FileEnumerator enumerator = dir.enumerate_children (FileAttribute.STANDARD_NAME, 0, null); + var info = enumerator.next_file (null); + while (info != null) { + string child_name = info.get_name (); + File child_file = dir.resolve_relative_path (child_name); + if (info.get_file_type () == FileType.DIRECTORY) { + if (!info.get_is_hidden ()) { + check_directory (child_file); } + } else if (info.get_file_type () == FileType.REGULAR) { + /* Check only .vala files */ + if (child_name.length > 5 && child_name.has_suffix (".vala")) { + check_file (child_file); + } + } + info = enumerator.next_file (null); + } + } + + void check_file (File file) throws Error, IOError { + Gee.ArrayList mistakes = linter.run_checks_for_file (file); + + if (!mistakes.is_empty) { + application_command_line.print ("\x001b[1m\x001b[4m" + "%s" + "\x001b[0m\n", file.get_path ()); + + foreach (FormatMistake mistake in mistakes) { + application_command_line.print ("\x001b[0m%5i:%-3i \x001b[1m%-40s \x001b[0m%s\n", + mistake.line_index, + mistake.char_index, + mistake.mistake, + mistake.check.get_title ()); } } }