Hi all,
as discussed in the previous mails to avoid syntax errors in the Perl files I have
added a new check to Travis. It runs the Perl syntax check (using "perl -w -c") for
all *.pm and *.pl files found in the Git repository. The check is active for all Git
branches which use the Docker images at Travis. (See [1], [2] if you are interested
in the implementation details.)
The check fails when there is a syntax error, if there are just warnings it will
pass. But of course, that does not mean you should not try to fix the warnings as well.
I have tested the syntax check in all YaST modules which contain some Perl files,
no syntax error was found besides the users module which has just is been fixed [3].
But I run the check locally (outside Docker) so the environment might have been a bit
different than at Travis. In some cases we might need to install some more Perl
packages there (the syntax check actually loads all used Perl modules) or we might
need to adapt the Perl search path (via the PERL5LIB environment variable) to find
the source files.
If you need help with that or Travis fails for some other reason then just ping me.
[1] https://github.com/yast/docker-yast-ruby/pull/32
[2] https://github.com/yast/docker-yast-cpp/pull/23
[3] https://github.com/yast/yast-users/pull/193
--
Ladislav Slezák
YaST Developer
SUSE LINUX, s.r.o.
Corso IIa
Křižíkova 148/34
18600 Praha 8
--
To unsubscribe, e-mail: yast-devel+unsubscribe(a)opensuse.org
To contact the owner, e-mail: yast-devel+owner(a)opensuse.org
Hi,
some time ago I fixed a typo in an yast2-packager shell script. After fixing it [1] I
remembered that I had looked at the ShellCheck tool in the past. It is a similar tool
to Rubocop but designed for shell scripts. There is even an online version if you
want to do a quick test without installing it [2].
When I tried to run it on the original script it obviously found the error there.
My idea was to run this check also in Travis to avoid similar problems in the future
so I created a package in YaST:Head [3] and included it in the Travis image.
The package is already available in the Leap 15.0 but the Tumbleweed contains a newer
version which reports some more issues so I copied the TW version to YaST:Head and
built it also for Leap 15.0.
If you want to run ShellCheck for your scripts in Travis see [4] how it was done in
the yast2-packager.
Last but not least, there is a good documentation (wiki) describing the rationales
and how to fix each reported issue, like [5]. So even when you are not a shell expert
you should be able to fix the reported issues quite easily.
Enjoy! :-)
P.S.: An interesting detail I found: Shellcheck looks quite smart, e.g. in
foo $bar
it complains that you should double quote the unknown $bar value, but with
bar=baz
foo $bar
it does not complain as it is actually not needed. With
bar="baz z"
foo $bar
it correctly complains again.
So it does not foolishly complain about double quotes everywhere, it evaluates the
context and the real values to avoid false positives. That's really nice!
[1] https://github.com/yast/yast-packager/pull/386/files
[2] https://www.shellcheck.net/
[3] https://build.opensuse.org/package/show/YaST:Head/ShellCheck
[4]
https://github.com/yast/yast-packager/blob/465cdbce77c24f008b9e36653abf4dea…
[5] https://github.com/koalaman/shellcheck/wiki/SC2086
--
Ladislav Slezák
YaST Developer
SUSE LINUX, s.r.o.
Corso IIa
Křižíkova 148/34
18600 Praha 8
--
To unsubscribe, e-mail: yast-devel+unsubscribe(a)opensuse.org
To contact the owner, e-mail: yast-devel+owner(a)opensuse.org
[shundhammer @ morgul] ~/tmp % cat weird.rb
#!/usr/bin/ruby
class Weird
attr_accessor :foo
def initialize
@foo = "foo"
end
def doit1
puts "doit1"
puts foo + "bar"
end
def doit2
puts "doit2"
puts foo +"bar"
end
end
weird = Weird.new
weird.doit1
weird.doit2
[shundhammer @ morgul] ~/tmp % ./weird.rb
doit1
foobar
doit2
Traceback (most recent call last):
1: from ./weird.rb:23:in `<main>'
./weird.rb:17:in `doit2': wrong number of arguments (given 1, expected 0)
(ArgumentError)
What's going on here?
Why does it crash?
What's the difference between "doit1" and "doit2"?
(Spoiler alert: solution after the blank lines)
Yes, it's just that one blank after the plus operator, and it makes all the
difference.
It turns out that some time ago (with Ruby 2.3), the Ruby string class got a
brand new unary plus operator (which is what we had all been missing for so
long, of course). That unary plus calls String.unfreeze on that string.
And in Ruby, the parentheses for a function call are optional.
This is an accident waiting to happen, and it happened right here:
Ruby interpreted this as a function call because the plus can be interpreted
as an unary plus here, so it decided to unfreeze the constant "bar" string
and pass it as an argument to the foo() method - which exists; it is the
getter to the @foo member variable (implicitly created by attr_accessor:
foo). Of course, this getter does not accept any parameter, so it complains.
Actually it's pure luck that it does not accept a parameter and complains
instead; if it had been a function that can accept a parameter, it would have
happily called it with the unfrozen "bar" string and just done random garbage
with that unintended parameter.
ARGH.
This is when "meaning good" (as in "the opposite of doing good") meets duck
typing and happily executing any random garbage.
If I really want to unfreeze a frozen string, I will happily tell Ruby to do
just that. But no, there was a chance to make a cryptic scripting language
even more cryptic by introducing stuff like an unary plus operator for
strings, of all things.
Tricky programming is soooo cool.
Readable and maintainable code is sooo overrated.
ARGH.
Kind regards
--
Stefan Hundhammer <shundhammer(a)suse.de>
YaST Developer
SUSE Linux GmbH
GF: Felix Imendörffer, Jane Smithard, Graham Norton; HRB 21284 (AG Nürnberg)
Maxfeldstr. 5, 90409 Nürnberg, Germany
--
To unsubscribe, e-mail: yast-devel+unsubscribe(a)opensuse.org
To contact the owner, e-mail: yast-devel+owner(a)opensuse.org
IMPORTANT: DO NOT REPLY ON THIS LIST!!!
IMPORTANT: DO NOT REPLY ON THIS LIST!!!
Replies or comments should be made on the openSUSE Project Mailing List.
Private replies or comments can be made to the Elections Committee
through the address election-officials(a)opensuse.org
********
Hello, openSUSE Contributors:
It seems that several of our best Contributors in the openSUSE Project
do not have their openSUSE Membership, and in fact think that it is not
important or even that it is a "bother".
However, we would like to point out to those of you who do not have your
Membership, and who make other such important Contributions to
openSUSE, that a Healthy Project is only as Healthy as its Members.
And, especially important, Membership is required in order to vote for
the openSUSE Board.
We on the Elections Committee think that the people who should *most* be
taking part in the Voting process are the hard-lifters, such as the
Heroes, the Developers, the Maintainers, the Packagers, the project's
Coders, and all the Heavy Lifters.
Therefore, we appeal to those of you who do NOT have their Membership to
please apply:
Get your openSUSE Membership, it is important for a Healthy Project.
<url>https://en.opensuse.org/openSUSE:Members#How_to_become_a_Member</url>
<url>https://en.opensuse.org/openSUSE:Members</url>
We know you are tremendously busy, but if any of you think you can spare
the time, we also would like you to consider running as a Candidate in
the 2018-2019 Board Elections.
<url>https://en.opensuse.org/openSUSE:Board_election</url>
We really would prefer not to see this:
<url>https://news.opensuse.org/2019/01/04/no-candidates-board-might-be-forced-to…</url>
Thank You,
--
from:
The Elections Committee:
election-officials(a)opensuse.org
M. Edwin Zakaria
Ish Sookun
Gerry Makaro
--
To unsubscribe, e-mail: yast-devel+unsubscribe(a)opensuse.org
To contact the owner, e-mail: yast-devel+owner(a)opensuse.org