File: ProhibitMixedBooleanOperators.run

package info (click to toggle)
libperl-critic-perl 1.156-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,544 kB
  • sloc: perl: 24,092; lisp: 341; makefile: 7
file content (86 lines) | stat: -rw-r--r-- 2,106 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
## name High-precedence passing
## failures 0
## cut

next if ! $finished || $foo < $bar;
if( $foo && !$bar || $baz){ do_something() }
this() && !that() || the_other();

#-----------------------------------------------------------------------------

## name Low-precedence passing
## failures 0
## cut

next if not $finished or $foo < $bar;
if( $foo and not $bar or $baz){ do_something() }
this() and not that() or the_other();

#-----------------------------------------------------------------------------

## name Basic failure
## failures 3
## cut

next if not $finished || $foo < $bar;
if( $foo && not $bar or $baz){ do_something() }
this() and ! that() or the_other();

#-----------------------------------------------------------------------------

## name High-precedence with low precedence self-equals
## failures 0
## cut

$sub ||= sub {
   return 1 and 2;
};

#-----------------------------------------------------------------------------

## name Mixed booleans in same statement, but different expressions
## failures 0
## cut

# See http://rt.cpan.org/Ticket/Display.html?id=27637
ok( ! 1, 'values are URLs' ) or diag 'never happens';

#-----------------------------------------------------------------------------

## name Mixed booleans in code blocks
## failures 0
## cut

eval {
    if (1 || 2) {
        return not 3;
    }
};

#-----------------------------------------------------------------------------

## name Mixed booleans with ||= and &&= operators (https://github.com/adamkennedy/PPI/issues/74)
## failures 2
## cut

$foo ||= $this or $that;
$foo &&= $this or $that;

#-----------------------------------------------------------------------------

## name With a postfix control (GH #496)
## TODO need to treat left and right sides separately
## failures 0
## cut

$value ||= 1 if 1 and 1;

##############################################################################
# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 78
#   indent-tabs-mode: nil
#   c-indentation-style: bsd
# End:
# ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround :