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

pre-commit: add hook to auto trim trailing whitespace #277

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ repos:
files: \.(hxx|java|md|mk|pl|pm|py|sh|ya?ml)$|^test/.*$
- id: mixed-line-ending
files: ^main/.*\.(c|h)xx$
- id: trailing-whitespace
files: \.pl$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
Expand Down
26 changes: 13 additions & 13 deletions main/cli_ure/source/scripts/increment_version.pl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#**************************************************************
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
#**************************************************************


Expand All @@ -32,16 +32,16 @@
sub incrementNewVersion($);
sub incrementOldVersion($);
sub incrementPolicyVersion($);
my $usage =
"The tool increments the minor version of assemblies and the major version of ".
my $usage =
"The tool increments the minor version of assemblies and the major version of ".
"the respective policy files. This is only done if new uno types have been added since".
"the last product update. This information is obtained from the file which is passed as ".
"argument changedTypes. The names in the version file must have a particular form. ".
"They must end on one of following terms: NEW_VERSION, OLD_VERSION, POLICY_VERSION\n".
"If no new published types have been added then no output, argument newVersions, is written".
"Usage is: \n increment_version.pl oldVersions incVersions newVersions changedTypes\n\n".
"oldVersion: Contains name value pairs, which are used for forming the config files of ".
"the policy assemblies, for building the assemblies. \n\n".
"the policy assemblies, for building the assemblies. \n\n".
"incVersions: File containing the names of which the versions are to be incremented. ".
"Every line may only contain one name. The names must exactly match those from the ".
"oldVersion file.\n\n".
Expand All @@ -54,7 +54,7 @@
"The names must end on one of these names: NEW_VERSION, OLD_VERSION, POLICY_VERSION\n".
"For example, valid names are: \n".
"CLI_URETYPES_NEW_VERSION\nCLI_URETYPES_OLD_VERSION\nCLI_URETYPES_POLICY_VERSION\n";

if (scalar @ARGV < 4) {
print $usage;
exit -1;
Expand Down Expand Up @@ -111,7 +111,7 @@
#read in oldVersions line by line and apply the increment operation
open OLDVERSION, "$ARGV[0]" or die "Cannot open to $ARGV[0] $!";

#open file we want to write to
#open file we want to write to
open NEWVERSION, "> $ARGV[2]" or die "Cannot write to $ARGV[2] $!";

print NEWVERSION processLine($_, @incVersions) while(<OLDVERSION>);
Expand Down Expand Up @@ -148,9 +148,9 @@ ($$)
my $value = substr($line, $i + 1);
$value = trim($value);

#Check if the entry shall be incremented, this information is in the second
#Check if the entry shall be incremented, this information is in the second
#argument
my $found;
my $found;
for(@incVersions) {
if ($_ eq $name) {
$found = 1;
Expand All @@ -160,7 +160,7 @@ ($$)
if ( ! defined($found)) {
return $line;
}

#Check if the name represents a version we need to change
if ($name =~ /NEW_VERSION$/)
{
Expand Down Expand Up @@ -235,7 +235,7 @@ ($)
my $arg = $_[0];
my @names;

while(<INC>)
while(<INC>)
{
chomp;
#Skip empty lines
Expand Down
24 changes: 12 additions & 12 deletions main/cli_ure/source/scripts/subst_template.pl
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#**************************************************************
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
#**************************************************************


Expand All @@ -28,9 +28,9 @@
sub trim;
sub readRedirectionValues($);

my $usage =
my $usage =
"Usage is: \n subst_template.pl configTemplate redirections policyConfig

configTemplate: The config file which is used for the policy assembly. It
contains place holders for the binding redirection.

Expand All @@ -40,7 +40,7 @@
policyConfig: Name of the file in which we want to write the config file.
";


if (scalar @ARGV < 3) {
print $usage;
exit -1;
Expand Down Expand Up @@ -85,36 +85,36 @@ ($)
if (length($trimmed = trim($_)) == 0) {
next;
}

#Skip comment symbol: #
if ($trimmed =~ /^#/) {
next;
}

my @lineParts = split /=/,$_;

#Check if we have valid name value pairs.
if (scalar @lineParts != 2) {
print "Error: Values in $ARGV[1] are not correct (Entries must have the form name=value). Invalid line: \n$_\n";
exit -1;
}

#Trim the strings and check if they still contain characters
my $name = trim($lineParts[0]);
my $value = trim($lineParts[1]);
if (length($name) == 0 || length($value) == 0) {
print "Error: Values in $ARGV[1] are not correct. Invalid line: \n$_\n";
exit -1;
}

#Check if we have duplicate key names
for (keys %redirectionValues) {
if ( $name eq $_) {
print "Error: Values in $ARGV[1] are not correct. The name $_ is not unique.\n";
exit -1;
}
}

$redirectionValues{$name} = $value;
}
return %redirectionValues;
Expand Down
22 changes: 11 additions & 11 deletions main/cppuhelper/test/testdefaultbootstrapping.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
eval 'exec perl -wS $0 ${1+"$@"}'
if 0;
#**************************************************************
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
#**************************************************************


Expand Down Expand Up @@ -54,7 +54,7 @@
sub extendProgName($) {
my $_extension = shift;
my $_result;

if ($ENV{GUI} eq "WNT") {
$_result = $progname . $_extension;
}
Expand Down Expand Up @@ -127,21 +127,21 @@ ()
$comment = $comment . "\tcouldn't unregister service " . $service . "\n";
$state = 0;
}


# register the service and ensure that it is reachable
$rc = registerService($services{$service}, $service . '.rdb');
if(!$rc) {
$comment = $comment . "\tcouldn't register service " . $service . "\n";
$state = 0;
}

$rc = testForServices([$service], "-env:UNO_SERVICES=" . $service . ".rdb", $testexe);
if(!$rc) {
$comment = $comment . "\tcouldn't reach service " . $service . "\n";
$state = 0;
}

# memorize all services
if (length($allservices_rdbs)) {
$allservices_rdbs = $allservices_rdbs . " ";
Expand All @@ -165,7 +165,7 @@ ()
my $service = 'com.sun.star.reflection.CoreReflection';
my $_testexe;

my @_exes = (extendProgName(".exe"),
my @_exes = (extendProgName(".exe"),
extendProgName(".Exe"),
extendProgName(".bin"),
extendProgName(".Bin"));
Expand Down Expand Up @@ -239,7 +239,7 @@ ()
# test that all services are reachable through different rdbs
# change the directory to ensure, that all paths become expanded
chdir "..";

$rc = testForServices(\@allservices, "-env:UNO_SERVICES=" . $allservices_rdbs, $testexe);
if (!$rc) {
$comment = $comment . "\tmulti rdb test not passed\n";
Expand Down
18 changes: 9 additions & 9 deletions main/extensions/source/update/check/transform.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
if 0;

#**************************************************************
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
#**************************************************************



while (<>) {

if( /<prop/ ) {
$prop = $_;
$prop = $_;
next if( /Text/ || /Bubble/ );
}

if( /<\/prop>/ ) {
next if( $prop =~ /Text/ || $prop =~ /Bubble/ );
}
}

if( /xml:lang/ ) {
$lang = $_;
$lang =~ s/.*xml:lang=\"//;
Expand All @@ -52,6 +52,6 @@
print $line;
next;
}

print;
}
10 changes: 5 additions & 5 deletions main/helpcontent2/helpers/checkuno.pl
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/usr/bin/env perl
# *************************************************************
#
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#
# *************************************************************

$uno_hid = "/handbuch/WORKBENCH/helpcontent2/helpers/uno_hid.lst";
Expand All @@ -28,7 +28,7 @@
while (<HID>) {
chomp;
($shid,$nhid,$uno) = split ",";
$hid{lc($uno)} = $shid;
$hid{lc($uno)} = $shid;
}
close HID;
} else {
Expand Down
Loading