Skip to content

Commit

Permalink
Fix copyright checker for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
iszmais committed Jul 3, 2024
1 parent d63a010 commit d5f2559
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 177 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\RepositoryObject;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function base()
{
//Init Factory and Renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\RepositoryObject;

/* Copyright (c) 2018 Jesús López <[email protected]> Extended GPL, see docs/LICENSE */

function with_object_icon()
{
//Init Factory and Renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\RepositoryObject;

/* Copyright (c) 2018 Jesús López <[email protected]> Extended GPL, see docs/LICENSE */

function with_object_icon_and_actions()
{
//Init Factory and Renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\RepositoryObject;

/* Copyright (c) 2018 Jesús López <[email protected]> Extended GPL, see docs/LICENSE */

function with_object_icon_and_certificate()
{
//Init Factory and Renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\RepositoryObject;

/* Copyright (c) 2018 Jesús López <[email protected]> Extended GPL, see docs/LICENSE */

function with_object_icon_and_progressmeter_mini()
{
//Init Factory and Renderer
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Card/Standard/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\Standard;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function base()
{
//Init Factory and Renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\Standard;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function with_sections()
{
//Init Factory and Renderer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Card\Standard;

/* Copyright (c) 2016 Jesús López <[email protected]> Extended GPL, see docs/LICENSE */

function with_title_action()
{
//Init Factory and Renderer
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Chart/ScaleBar/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

declare(strict_types=1);

/* Copyright (c) 2017 Alex Killing <[email protected]> Extended GPL, see docs/LICENSE */

namespace ILIAS\UI\examples\Chart\ScaleBar;

function base()
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Chart/ScaleBar/ten_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

declare(strict_types=1);

/* Copyright (c) 2017 Alex Killing <[email protected]> Extended GPL, see docs/LICENSE */

namespace ILIAS\UI\examples\Chart\ScaleBar;

function ten_items()
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Deck/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Deck;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function base()
{
//Init Factory and Renderer
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Deck/repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Deck;

/* Copyright (c) 2018 Jesús López <[email protected]> Extended GPL, see docs/LICENSE */

function repository()
{
//Init Factory and Renderer
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Deck/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Deck;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function user()
{
//Init Factory and Renderer
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Deck/xl_card.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Deck;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function xl_card()
{
//Init Factory and Renderer
Expand Down
16 changes: 0 additions & 16 deletions components/ILIAS/UI/src/examples/Input/Field/ColorPicker/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

namespace ILIAS\UI\examples\Input\Field\ColorPicker;

/**
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Legacy/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Legacy;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function base()
{
//Init Factory and Renderer
Expand Down
2 changes: 0 additions & 2 deletions components/ILIAS/UI/src/examples/Legacy/inside_panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

namespace ILIAS\UI\examples\Legacy;

/* Copyright (c) 2016 Timon Amstutz <[email protected]> Extended GPL, see docs/LICENSE */

function inside_panel()
{
//Init Factory and Renderer
Expand Down
16 changes: 0 additions & 16 deletions components/ILIAS/UI/src/examples/Player/Audio/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

namespace ILIAS\UI\examples\Player\Audio;

function base()
Expand Down
16 changes: 0 additions & 16 deletions components/ILIAS/UI/src/examples/Player/Video/video_mp4.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

namespace ILIAS\UI\examples\Player\Video;

function video_mp4(): string
Expand Down
16 changes: 0 additions & 16 deletions components/ILIAS/UI/src/examples/Player/Video/video_mp4_poster.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

namespace ILIAS\UI\examples\Player\Video;

function video_mp4_poster(): string
Expand Down
16 changes: 0 additions & 16 deletions components/ILIAS/UI/src/examples/Player/Video/video_vimeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

namespace ILIAS\UI\examples\Player\Video;

function video_vimeo(): string
Expand Down
16 changes: 0 additions & 16 deletions components/ILIAS/UI/src/examples/Player/Video/video_youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@

declare(strict_types=1);

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

namespace ILIAS\UI\examples\Player\Video;

function video_youtube(): string
Expand Down
15 changes: 0 additions & 15 deletions components/ILIAS/UI/src/examples/Symbol/Glyph/Launch/launch.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
<?php
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,4 @@
<?php
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

Expand Down
49 changes: 30 additions & 19 deletions scripts/Copyright-Checker/copyright-checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,35 @@ function is_copyright_valid() {
local file_extension="${file##*.}"
local offset=1

# since PSR-12 the php files will contain the copyright license as
# document-level comment, which starts on line 3.
if [ "php" = "${file_extension}" ]; then
offset=3
fi
is_ui_example ${file}
local is_example=${?}

for copyright_line in "${COPYRIGHT_LINES[@]}"; do
local line_to_check="$(sed "${offset}q;d" "${file}")"
if ! [ "${copyright_line}" = "${line_to_check}" ]; then
return 1
if [ 1 -eq ${is_example} ]; then
if [ "php" = ${file_extension} ]; then
offset=3
fi

offset=$((1 + ${offset}))
done
for copyright_line in "${COPYRIGHT_LINES[@]}"; do
local line_to_check="$(sed "${offset}q;d" "${file}")"
if ! [ "${copyright_line}" = "${line_to_check}" ]; then
return 1
fi

offset=$((1 + ${offset}))
done
else
local lines=$(wc -l < ${file});
while [ ${offset} -lt ${lines} ]
do
local line_to_check="$(echo "$(sed "${offset}q;d" ${file})" | xargs)"
if [[ "${line_to_check}" == "namespace "* ]]; then
return 0
fi
if [[ "${line_to_check}" == "/*"* || "${line_to_check}" == "//"* || "${line_to_check}" == "#"* ]]; then
return 2
fi
offset=$((1 + ${offset}))
done
fi

return 0
}
Expand Down Expand Up @@ -156,15 +171,11 @@ function perform_copyright_check() {
is_copyright_valid "${file}"
local is_valid="${?}"

is_ui_example "${file}"
local is_example="${?}"

# invert the copyright-check for UI examples, because we
# don't want them to have too much content.
if ([ 0 -eq ${is_example} ] && [ 0 -eq ${is_valid} ]) ||
([ 1 -eq ${is_example} ] && [ 1 -eq ${is_valid} ]); then
if [ 1 -eq ${is_valid} ]; then
printf "copyright is not as expected in %s\n" "${file}"
exit_status=1
elif [ 2 -eq ${is_valid} ]; then
printf "copyright is not allowed in %s\n" "${file}"
fi
done

Expand Down

0 comments on commit d5f2559

Please sign in to comment.