From 606592bb04b57430a5b469d50c0cb53f0cbf4b37 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Fri, 18 Oct 2019 16:59:21 +0200 Subject: [PATCH] add flymake-perlcritic --- .../bin/flymake_perlcritic | 44 +++++++++ .../flymake-perlcritic-autoloads.el | 27 ++++++ .../flymake-perlcritic-pkg.el | 10 +++ .../flymake-perlcritic.el | 90 +++++++++++++++++++ elpa/flymake-perlcritic-readme.txt | 3 + 5 files changed, 174 insertions(+) create mode 100755 elpa/flymake-perlcritic-20120328.814/bin/flymake_perlcritic create mode 100644 elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-autoloads.el create mode 100644 elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-pkg.el create mode 100644 elpa/flymake-perlcritic-20120328.814/flymake-perlcritic.el create mode 100644 elpa/flymake-perlcritic-readme.txt diff --git a/elpa/flymake-perlcritic-20120328.814/bin/flymake_perlcritic b/elpa/flymake-perlcritic-20120328.814/bin/flymake_perlcritic new file mode 100755 index 00000000..4b931121 --- /dev/null +++ b/elpa/flymake-perlcritic-20120328.814/bin/flymake_perlcritic @@ -0,0 +1,44 @@ +#!/bin/bash +# +# Wrapper around perlcritic and perl -c for Emacs flymake. + +showhelp() { + echo "flymake_perlcritic [-I ] [-h] + +Run perlcritic and \"perl -c\" on in a manner appropriate for use by Emacs flymake-perlcritic.el. + + -I Add the supplied dir to \$PERL5LIB include paths. + -h Display this help. + The source file to run the checks on."; + exit 0; +} + +while getopts "I:h" "OPTNAME"; +do + case $OPTNAME in + I) INCLUDE=$OPTARG ;; + h) showhelp ;; + *) exit -1 ;; + esac +done +shift $(($OPTIND - 1)) + +FILE_NAME="$1" +shift + +if [ -n "$INCLUDE" ]; then + if [ -n "$PERL5LIB" ]; then + export PERL5LIB="$INCLUDE:$PERL5LIB" + else + export PERL5LIB="$INCLUDE" + fi +fi + +# Run perlcritic first. +# TODO: be nice to include severity and have it turn into warning/error. +perlcritic --nocolour "$FILE_NAME" --verbose "%f:%l:%c: Warning: %m. %e.\n" $* + +# Run perl -c too for good measure. +perl -wc -Mstrict "$FILE_NAME" + +exit 0 \ No newline at end of file diff --git a/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-autoloads.el b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-autoloads.el new file mode 100644 index 00000000..49630e46 --- /dev/null +++ b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-autoloads.el @@ -0,0 +1,27 @@ +;;; flymake-perlcritic-autoloads.el --- automatically extracted autoloads +;; +;;; Code: + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + + +;;;### (autoloads nil "flymake-perlcritic" "flymake-perlcritic.el" +;;;;;; (0 0 0 0)) +;;; Generated autoloads from flymake-perlcritic.el + +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "flymake-perlcritic" '("flymake-perlcritic-"))) + +;;;*** + +;;;### (autoloads nil nil ("flymake-perlcritic-pkg.el") (0 0 0 0)) + +;;;*** + +;; Local Variables: +;; version-control: never +;; no-byte-compile: t +;; no-update-autoloads: t +;; coding: utf-8 +;; End: +;;; flymake-perlcritic-autoloads.el ends here diff --git a/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-pkg.el b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-pkg.el new file mode 100644 index 00000000..6f85c8e8 --- /dev/null +++ b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic-pkg.el @@ -0,0 +1,10 @@ +(define-package "flymake-perlcritic" "20120328.814" "Flymake handler for Perl to invoke Perl::Critic" + '((flymake "0.3")) + :authors + '(("Sam Graham ")) + :maintainer + '("Sam Graham ") + :url "https://github.com/illusori/emacs-flymake-perlcritic") +;; Local Variables: +;; no-byte-compile: t +;; End: diff --git a/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic.el b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic.el new file mode 100644 index 00000000..e7a117b6 --- /dev/null +++ b/elpa/flymake-perlcritic-20120328.814/flymake-perlcritic.el @@ -0,0 +1,90 @@ +;;; flymake-perlcritic.el --- Flymake handler for Perl to invoke Perl::Critic +;; +;; Copyright (C) 2011-2012 Free Software Foundation, Inc. +;; +;; Author: Sam Graham +;; Maintainer: Sam Graham +;; URL: https://github.com/illusori/emacs-flymake-perlcritic +;; Version: 1.0.3 +;; Package-Requires: ((flymake "0.3")) +;; +;; This program is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . +;; +;;; Commentary: +;; +;; flymake-perlcritic.el adds support to flymake.el for running Perl::Critic +;; (http://search.cpan.org/perldoc?Perl::Critic) to perform static +;; analysis of your Perl code in addition to syntax checking. +;; +;;; Usage: +;; (require 'flymake-perlcritic) + +(eval-when-compile (require 'flymake)) + +(defcustom flymake-perlcritic-command (executable-find + (concat (file-name-directory (or load-file-name buffer-file-name)) + "bin/flymake_perlcritic")) + "If flymake_perlcritic isn't in your $PATH, set this to the command needed to run it." + :group 'flymake-perlcritic + :type 'string) + +(defcustom flymake-perlcritic-profile nil + "The path to the profile file to configure perlcritic, if nil then perlcritic will look in its default location (~/.perlcriticrc)." + :group 'flymake-perlcritic + :type 'string) + +(defcustom flymake-perlcritic-severity 4 + "The severity to run perlcritic at, values are 1 to 5 with 1 being strictest." + :group 'flymake-perlcritic + :type 'integer) + +(defun flymake-perlcritic-init () + (let* ((temp-file (flymake-init-create-temp-buffer-copy + 'flymake-create-temp-with-folder-structure)) + (local-file (file-relative-name temp-file + (file-name-directory buffer-file-name))) + (include-dir (if (fboundp 'flymake-find-perl-lib-dir) + (flymake-find-perl-lib-dir buffer-file-name)))) + (if (fboundp 'flymake-perlbrew-path-sync) + (flymake-perlbrew-path-sync)) + (list flymake-perlcritic-command + (append + (if include-dir (list (concat "-I" include-dir))) + (list local-file) + (if flymake-perlcritic-profile (list "--profile" flymake-perlcritic-profile)) + (list "--severity" (number-to-string flymake-perlcritic-severity)))))) + +(defun flymake-perlcritic-cleanup () + "Cleanup after `flymake-perlcritic-init' - delete temp file and dirs." + (flymake-safe-delete-file flymake-temp-source-file-name) + (when flymake-temp-source-file-name + (flymake-delete-temp-directory + (file-name-directory flymake-temp-source-file-name)))) + +(eval-after-load "flymake" + '(progn + ;; Add a new error pattern to catch Perl::Critic output, this is a custom + ;; format defined in perlcritic_flymake since the Perl::Critic default + ;; isn't parsable in a way that flymake.el likes. + (add-to-list 'flymake-err-line-patterns + '("\\(.*\\):\\([0-9]+\\):\\([0-9]+\\): \\(.*\\)" 1 2 3 4)) + (let ((mode-and-masks (flymake-get-file-name-mode-and-masks "example.pm"))) + (setcar mode-and-masks 'flymake-perlcritic-init) + (if (nth 1 mode-and-masks) + (setcar (nthcdr 1 mode-and-masks) 'flymake-perlcritic-cleanup) + (nconc mode-and-masks (list 'flymake-perlcritic-cleanup)))) + (add-hook 'perl-mode-hook (lambda() (flymake-mode 1)) t))) + +(provide 'flymake-perlcritic) +;;; flymake-perlcritic.el ends here diff --git a/elpa/flymake-perlcritic-readme.txt b/elpa/flymake-perlcritic-readme.txt new file mode 100644 index 00000000..78633779 --- /dev/null +++ b/elpa/flymake-perlcritic-readme.txt @@ -0,0 +1,3 @@ +flymake-perlcritic.el adds support to flymake.el for running Perl::Critic +(http://search.cpan.org/perldoc?Perl::Critic) to perform static +analysis of your Perl code in addition to syntax checking. -- 2.47.3