codeformunich / muenchen-transparent

Ein alternatives Ratsinformationssystem mit E-Mail-Benachrichtigungen, Volltextsuche und vielem mehr.
https://www.muenchen-transparent.de
GNU Affero General Public License v3.0
50 stars 8 forks source link

Doppelten Code entfernen #120

Closed konstin closed 6 years ago

konstin commented 8 years ago

In einigen PHP-Dateien mit ähnlichen Aufgaben findet sich identischer oder sehr ähnlicher code, der entfernt werden sollte.

Die Dateien, bei denen das der Fall ist, lassen sich gut mit tools wie phpcpd finden:

phpcpd 2.0.2 by Sebastian Bergmann.

Found 8 exact clones with 236 duplicated lines in 11 files:

  - /home/konsti/Ratsinformant/protected/models/Tagesordnungspunkt.php:51-107
    /home/konsti/Ratsinformant/protected/models/TagesordnungspunktHistory.php:51-107

  - /home/konsti/Ratsinformant/protected/models/AntragHistory.php:90-116
    /home/konsti/Ratsinformant/protected/models/Antrag.php:155-181

  - /home/konsti/Ratsinformant/protected/config/main.template.php:58-119
    /home/konsti/Ratsinformant/protected/config/main.php:58-119

  - /home/konsti/Ratsinformant/protected/RISParser/BAAntragParser.php:193-219
    /home/konsti/Ratsinformant/protected/RISParser/StadtratsvorlageParser.php:274-300

  - /home/konsti/Ratsinformant/protected/RISParser/StadtratsvorlageParser.php:154-160
    /home/konsti/Ratsinformant/protected/RISParser/StadtratsantragParser.php:119-125

  - /home/konsti/Ratsinformant/protected/RISParser/BAAntragParser.php:116-132
    /home/konsti/Ratsinformant/protected/RISParser/BAInitiativeParser.php:107-123

  - /home/konsti/Ratsinformant/protected/RISParser/BAAntragParser.php:193-218
    /home/konsti/Ratsinformant/protected/RISParser/BAInitiativeParser.php:180-205

  - /home/konsti/Ratsinformant/protected/controllers/AntraegeController.php:75-95
    /home/konsti/Ratsinformant/protected/controllers/AntraegeController.php:104-124

1.12% duplicated lines out of 21085 total lines of code.

Time: 287 ms, Memory: 23.00Mb

Idealerweise sollte die Suche nach doppeltem Code automatisiert durchgeführt werden.

akuckartz commented 8 years ago

:+1:

konstin commented 8 years ago

codeclimate hat das noch etwas besser analysiert: https://codeclimate.com/github/codeformunich/Muenchen-Transparent/issues/categories/duplication