Skip to content

Conversation

okumin
Copy link
Contributor

@okumin okumin commented Oct 9, 2025

What changes were proposed in this pull request?

Normalize the license headers. This pull request aligns the depth of indents.

This PR affects numerous files, but most changes are whitespace-only. So, I recommend checking the diff with the w=1 option or git diff master...HIVE-29245-regex-indent -w.

Originally, I attempted to update all at once in #6115, but it is likely to be difficult to review. So, I created a separate pull request focusing on whitespace changes.

Why are the changes needed?

Our CI checks the license header format of new files. Some (or most) people copy and paste the header from existing Java files. Unfortunately, existing files don't share the same format, and SonarQube often reports a license issue. A reviewer has to say "you must not copy and paste the header from existing files, you must pick it up from checkstyle/asf.header.

Does this PR introduce any user-facing change?

No

How was this patch tested?

I put the following configuration on checkstyle/checkstyle.xml, standalone-metastore/checkstyle/checkstyle.xml, and storage-api/checkstyle/checkstyle.xml. After that, I ran mvn checkstyle:check`.

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
  <module name="Checker">
    <module name="RegexpHeader">
      <property name="headerFile" value="${config_loc}/asf.header.incremental"/>
      <property name="fileExtensions" value="java"/>
      <property name="multiLines" value="2"/>
    </module>
  </module>

okumin added 9 commits October 9, 2025 12:27
git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^(\s*\*)(?! {5}http://)\s*http://www\.apache\.org/licenses/LICENSE-2\.0$|\1     http://www.apache.org/licenses/LICENSE-2.0|'
git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  Licensed to the Apache Software Foundation \(ASF\) under one$| * Licensed to the Apache Software Foundation (ASF) under one|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  or more contributor license agreements\.  See the NOTICE file$| * or more contributor license agreements.  See the NOTICE file|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  distributed with this work for additional information$| * distributed with this work for additional information|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  regarding copyright ownership\.  The ASF licenses this file$| * regarding copyright ownership.  The ASF licenses this file|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  to you under the Apache License, Version 2\.0 \(the$| * to you under the Apache License, Version 2.0 (the|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  "License"\); you may not use this file except in compliance$| * "License"); you may not use this file except in compliance|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  with the License.  You may obtain a copy of the License at$| * with the License.  You may obtain a copy of the License at|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  Unless required by applicable law or agreed to in writing, software$| * Unless required by applicable law or agreed to in writing, software|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  distributed under the License is distributed on an "AS IS" BASIS,$| * distributed under the License is distributed on an "AS IS" BASIS,|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  See the License for the specific language governing permissions and$| * See the License for the specific language governing permissions and|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  limitations under the License\.$| * limitations under the License.|'
git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -0777 -pi -e 's/\A(?:\x{FEFF})?[ \t]+\/\*\s*(\r?\n)/\/\*$1/'
git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* Licensed to the Apache Software Foundation \(ASF\) under one$| * * Licensed to the Apache Software Foundation (ASF) under one|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* or more contributor license agreements\.  See the NOTICE file$| * * or more contributor license agreements.  See the NOTICE file|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* distributed with this work for additional information$| * * distributed with this work for additional information|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* regarding copyright ownership\.  The ASF licenses this file$| * * regarding copyright ownership.  The ASF licenses this file|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* to you under the Apache License, Version 2\.0 \(the$| * * to you under the Apache License, Version 2.0 (the|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* "License"\); you may not use this file except in compliance$| * * "License"); you may not use this file except in compliance|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* with the License.  You may obtain a copy of the License at$| * * with the License.  You may obtain a copy of the License at|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* Unless required by applicable law or agreed to in writing, software$| * * Unless required by applicable law or agreed to in writing, software|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* distributed under the License is distributed on an "AS IS" BASIS,$| * * distributed under the License is distributed on an "AS IS" BASIS,|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$| * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* See the License for the specific language governing permissions and$| * * See the License for the specific language governing permissions and|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \* limitations under the License\.$| * * limitations under the License.|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \*$| * *|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  \*     http://www.apache.org/licenses/LICENSE-2.0$| * *     http://www.apache.org/licenses/LICENSE-2.0|'
git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  you may not use this file except in compliance with the License\.$| * you may not use this file except in compliance with the License.|'

git ls-files '*.java' | grep -v 'src/gen/thrift' | grep -v '^iceberg/' \
  | xargs perl -pi -e 's|^ \*  You may obtain a copy of the License at$| * You may obtain a copy of the License at|'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants