Browse Source

Configure plugin ITs (aka it-platform)

tags/5.2-RC1
David Gageot 8 years ago
parent
commit
4b23bd740d
100 changed files with 23482 additions and 6 deletions
  1. 1
    0
      .travis.yml
  2. 1
    0
      it/it-projects/plugins/project/.gitignore
  3. 3
    0
      it/it-projects/plugins/project/build.sh
  4. 40
    0
      it/it-projects/plugins/project/ext/cobol/copybooks/Attr.cpy
  5. 9
    0
      it/it-projects/plugins/project/ext/cobol/copybooks/Custmas.cpy
  6. 6
    0
      it/it-projects/plugins/project/ext/cobol/copybooks/Errparm.cpy
  7. 181
    0
      it/it-projects/plugins/project/ext/cobol/copybooks/MNTSET2.CPY
  8. 2
    0
      it/it-projects/plugins/project/lib/c/mylib.h
  9. 30
    0
      it/it-projects/plugins/project/pom.xml
  10. 40
    0
      it/it-projects/plugins/project/sonar-project.properties
  11. 147
    0
      it/it-projects/plugins/project/src/abap/ZBCMKZ17.abap
  12. 194
    0
      it/it-projects/plugins/project/src/abap/ZZBGS106.abap
  13. 19
    0
      it/it-projects/plugins/project/src/c/main.c
  14. 581
    0
      it/it-projects/plugins/project/src/cobol/Custmnt2.cbl
  15. 17508
    0
      it/it-projects/plugins/project/src/cobol/TC4E3H0.CBL
  16. 51
    0
      it/it-projects/plugins/project/src/cpp/BiggestUnInt.cc
  17. 8
    0
      it/it-projects/plugins/project/src/cpp/HelloWorld.cpp
  18. 87
    0
      it/it-projects/plugins/project/src/cpp/RandDemo.cc
  19. 70
    0
      it/it-projects/plugins/project/src/cpp/SimpleClass.cc
  20. 18
    0
      it/it-projects/plugins/project/src/cpp/main.c
  21. 89
    0
      it/it-projects/plugins/project/src/css/sample.css
  22. 14
    0
      it/it-projects/plugins/project/src/flex/Circle.as
  23. 12
    0
      it/it-projects/plugins/project/src/flex/HasIssues.as
  24. 10
    0
      it/it-projects/plugins/project/src/flex/UncoveredCircle.as
  25. 7
    0
      it/it-projects/plugins/project/src/groovy/example/Greeting.groovy
  26. 14
    0
      it/it-projects/plugins/project/src/groovy/innerclass/InnerClassExample.groovy
  27. 15
    0
      it/it-projects/plugins/project/src/java/foo/Foo.java
  28. 17
    0
      it/it-projects/plugins/project/src/java/foo/Simplest.java
  29. 7
    0
      it/it-projects/plugins/project/src/java/foo/Simplest2.java
  30. 5
    0
      it/it-projects/plugins/project/src/java/foo/Simplest3.java
  31. 18
    0
      it/it-projects/plugins/project/src/js/HasIssues.js
  32. 14
    0
      it/it-projects/plugins/project/src/js/Person.js
  33. 50
    0
      it/it-projects/plugins/project/src/js/com/company/Car.js
  34. 24
    0
      it/it-projects/plugins/project/src/js/com/company/Truck.js
  35. 53
    0
      it/it-projects/plugins/project/src/js/com/company/Vehicle.js
  36. 214
    0
      it/it-projects/plugins/project/src/php/Math.php
  37. 212
    0
      it/it-projects/plugins/project/src/pli/center.pli
  38. 760
    0
      it/it-projects/plugins/project/src/pli/chess.pli
  39. 13
    0
      it/it-projects/plugins/project/src/pli/hasissues.pli
  40. 67
    0
      it/it-projects/plugins/project/src/pli/maxlen.pli
  41. 246
    0
      it/it-projects/plugins/project/src/pli/search.pli
  42. 9
    0
      it/it-projects/plugins/project/src/plsql/ddl.sql
  43. 213
    0
      it/it-projects/plugins/project/src/plsql/ut_report.pkb
  44. 0
    0
      it/it-projects/plugins/project/src/python/__init__.py
  45. 92
    0
      it/it-projects/plugins/project/src/python/badfortune.py
  46. 1
    0
      it/it-projects/plugins/project/src/python/directory/file_in_directory.py
  47. 8
    0
      it/it-projects/plugins/project/src/python/hasissues.py
  48. 0
    0
      it/it-projects/plugins/project/src/python/package/__init__.py
  49. 1
    0
      it/it-projects/plugins/project/src/python/package/file_in_package.py
  50. 0
    0
      it/it-projects/plugins/project/src/python/samples/__init__.py
  51. 92
    0
      it/it-projects/plugins/project/src/python/samples/fortune.py
  52. 203
    0
      it/it-projects/plugins/project/src/python/samples/letters.py
  53. 100
    0
      it/it-projects/plugins/project/src/python/samples/strfile.py
  54. 53
    0
      it/it-projects/plugins/project/src/rpg/MYPROGRAM.rpg
  55. 10
    0
      it/it-projects/plugins/project/src/swift/example.swift
  56. 67
    0
      it/it-projects/plugins/project/src/vb/Info.frm
  57. 166
    0
      it/it-projects/plugins/project/src/vb/Registry.bas
  58. 428
    0
      it/it-projects/plugins/project/src/vb/Registry.cls
  59. 48
    0
      it/it-projects/plugins/project/src/web/sample.xhtml
  60. BIN
      it/it-projects/plugins/project/target/classes/foo/Foo.class
  61. BIN
      it/it-projects/plugins/project/target/classes/foo/Simplest.class
  62. BIN
      it/it-projects/plugins/project/target/classes/foo/Simplest2.class
  63. BIN
      it/it-projects/plugins/project/target/classes/foo/Simplest3.class
  64. BIN
      it/it-projects/plugins/project/target/it-all-lang-1.0-SNAPSHOT.jar
  65. 71
    0
      it/it-projects/plugins/project/target/js/lcov.dat
  66. 101
    0
      it/it-projects/plugins/project/target/php/phpunit.coverage.xml
  67. 52
    0
      it/it-projects/plugins/project/target/php/phpunit.xml
  68. 66
    0
      it/it-projects/plugins/project/target/surefire-reports/TEST-foo.FooTest.xml
  69. 66
    0
      it/it-projects/plugins/project/target/surefire-reports/TEST-foo.SimplestTest.xml
  70. 4
    0
      it/it-projects/plugins/project/target/surefire-reports/foo.FooTest.txt
  71. 4
    0
      it/it-projects/plugins/project/target/surefire-reports/foo.SimplestTest.txt
  72. BIN
      it/it-projects/plugins/project/target/test-classes/foo/FooTest.class
  73. BIN
      it/it-projects/plugins/project/target/test-classes/foo/SimplestTest.class
  74. 12
    0
      it/it-projects/plugins/project/test/java/foo/FooTest.java
  75. 12
    0
      it/it-projects/plugins/project/test/java/foo/SimplestTest.java
  76. 13
    0
      it/it-projects/plugins/project/test/js/PersonTest.js
  77. 18
    0
      it/it-projects/plugins/project/test/js/com/company/CarTest.js
  78. 169
    0
      it/it-projects/plugins/project/test/php/SomeTest.php
  79. 8
    6
      it/it-tests/pom.xml
  80. 138
    0
      it/it-tests/src/test/java/plugins/PluginsTest.java
  81. 31
    0
      it/it-tests/src/test/java/plugins/Project.java
  82. 15
    0
      it/it-tests/src/test/java/plugins/checks/AbapCheck.java
  83. 15
    0
      it/it-tests/src/test/java/plugins/checks/CCheck.java
  84. 5
    0
      it/it-tests/src/test/java/plugins/checks/Check.java
  85. 15
    0
      it/it-tests/src/test/java/plugins/checks/CobolCheck.java
  86. 15
    0
      it/it-tests/src/test/java/plugins/checks/CppCheck.java
  87. 14
    0
      it/it-tests/src/test/java/plugins/checks/CssCheck.java
  88. 15
    0
      it/it-tests/src/test/java/plugins/checks/FlexCheck.java
  89. 15
    0
      it/it-tests/src/test/java/plugins/checks/GroovyCheck.java
  90. 15
    0
      it/it-tests/src/test/java/plugins/checks/JavaCheck.java
  91. 16
    0
      it/it-tests/src/test/java/plugins/checks/JavascriptCheck.java
  92. 15
    0
      it/it-tests/src/test/java/plugins/checks/PhpCheck.java
  93. 15
    0
      it/it-tests/src/test/java/plugins/checks/PliCheck.java
  94. 27
    0
      it/it-tests/src/test/java/plugins/checks/PythonCheck.java
  95. 15
    0
      it/it-tests/src/test/java/plugins/checks/RpgCheck.java
  96. 14
    0
      it/it-tests/src/test/java/plugins/checks/SwiftCheck.java
  97. 114
    0
      it/it-tests/src/test/java/plugins/checks/Validation.java
  98. 15
    0
      it/it-tests/src/test/java/plugins/checks/VbCheck.java
  99. 14
    0
      it/it-tests/src/test/java/plugins/checks/WebCheck.java
  100. 0
    0
      it/it-tests/src/test/resources/logback-test.xml

+ 1
- 0
.travis.yml View File

@@ -14,6 +14,7 @@ env:
- JOB=ITS_QUALITYGATE
- JOB=ITS_UPDATECENTER
- JOB=ITS_TESTING
- JOB=ITS_PLUGINS

matrix:
fast_finish: true

+ 1
- 0
it/it-projects/plugins/project/.gitignore View File

@@ -0,0 +1 @@
!target

+ 3
- 0
it/it-projects/plugins/project/build.sh View File

@@ -0,0 +1,3 @@
#!/bin/sh

mvn package

+ 40
- 0
it/it-projects/plugins/project/ext/cobol/copybooks/Attr.cpy View File

@@ -0,0 +1,40 @@
01 ATTRIBUTE-DEFINITIONS.
*
05 ATTR-UNPROT PIC X VALUE ' '.
05 ATTR-UNPROT-MDT PIC X VALUE X'C1'.
05 ATTR-UNPROT-BRT PIC X VALUE X'C8'.
05 ATTR-UNPROT-BRT-MDT PIC X VALUE X'C9'.
05 ATTR-UNPROT-DARK PIC X VALUE X'4C'.
05 ATTR-UNPROT-DARK-MDT PIC X VALUE X'4D'.
05 ATTR-UNPROT-NUM PIC X VALUE X'50'.
05 ATTR-UNPROT-NUM-MDT PIC X VALUE X'D1'.
05 ATTR-UNPROT-NUM-BRT PIC X VALUE X'D8'.
05 ATTR-UNPROT-NUM-BRT-MDT PIC X VALUE X'D9'.
05 ATTR-UNPROT-NUM-DARK PIC X VALUE X'5C'.
05 ATTR-UNPROT-NUM-DARK-MDT PIC X VALUE X'5D'.
05 ATTR-PROT PIC X VALUE X'60'.
05 ATTR-PROT-MDT PIC X VALUE X'61'.
05 ATTR-PROT-BRT PIC X VALUE X'E8'.
05 ATTR-PROT-BRT-MDT PIC X VALUE X'E9'.
05 ATTR-PROT-DARK PIC X VALUE '%'.
05 ATTR-PROT-DARK-MDT PIC X VALUE X'6D'.
05 ATTR-PROT-SKIP PIC X VALUE X'F0'.
05 ATTR-PROT-SKIP-MDT PIC X VALUE X'F1'.
05 ATTR-PROT-SKIP-BRT PIC X VALUE X'F8'.
05 ATTR-PROT-SKIP-BRT-MDT PIC X VALUE X'F9'.
05 ATTR-PROT-SKIP-DARK PIC X VALUE X'7C'.
05 ATTR-PROT-SKIP-DARK-MDT PIC X VALUE X'7D'.
*
05 ATTR-NO-HIGHLIGHT PIC X VALUE X'00'.
05 ATTR-BLINK PIC X VALUE '1'.
05 ATTR-REVERSE PIC X VALUE '2'.
05 ATTR-UNDERSCORE PIC X VALUE '4'.
*
05 ATTR-DEFAULT-COLOR PIC X VALUE X'00'.
05 ATTR-BLUE PIC X VALUE '1'.
05 ATTR-RED PIC X VALUE '2'.
05 ATTR-PINK PIC X VALUE '3'.
05 ATTR-GREEN PIC X VALUE '4'.
05 ATTR-TURQUOISE PIC X VALUE '5'.
05 ATTR-YELLOW PIC X VALUE '6'.
05 ATTR-NEUTRAL PIC X VALUE '7'.

+ 9
- 0
it/it-projects/plugins/project/ext/cobol/copybooks/Custmas.cpy View File

@@ -0,0 +1,9 @@
01 CUSTOMER-MASTER-RECORD.
*
05 CM-CUSTOMER-NUMBER PIC X(6).
05 CM-FIRST-NAME PIC X(20).
05 CM-LAST-NAME PIC X(30).
05 CM-ADDRESS PIC X(30).
05 CM-CITY PIC X(20).
05 CM-STATE PIC X(2).
05 CM-ZIP-CODE PIC X(10).

+ 6
- 0
it/it-projects/plugins/project/ext/cobol/copybooks/Errparm.cpy View File

@@ -0,0 +1,6 @@
01 ERROR-PARAMETERS.
*
05 ERR-RESP PIC S9(8) COMP.
05 ERR-RESP2 PIC S9(8) COMP.
05 ERR-TRNID PIC X(4) VALUE IS 99.
05 ERR-RSRCE PIC X(8).

+ 181
- 0
it/it-projects/plugins/project/ext/cobol/copybooks/MNTSET2.CPY View File

@@ -0,0 +1,181 @@
* Micro Focus BMS Screen Painter (ver MFBM 2.0.11)
* MapSet Name MNTSET2
* Date Created 04/16/2001
* Time Created 14:38:47

* Input Data For Map MNTMAP1
01 MNTMAP1I.
03 FILLER PIC X(12).
03 TRANID1L PIC S9(4) COMP.
03 TRANID1F PIC X.
03 FILLER REDEFINES TRANID1F.
05 TRANID1A PIC X.
03 FILLER PIC X(2).
03 TRANID1I PIC X(4).
03 CUSTNO1L PIC S9(4) COMP.
03 CUSTNO1F PIC X.
03 FILLER REDEFINES CUSTNO1F.
05 CUSTNO1A PIC X.
03 FILLER PIC X(2).
03 CUSTNO1I PIC X(6).
03 ACTIONL PIC S9(4) COMP.
03 ACTIONF PIC X.
03 FILLER REDEFINES ACTIONF.
05 ACTIONA PIC X.
03 FILLER PIC X(2).
03 ACTIONI PIC X(1).
03 MSG1L PIC S9(4) COMP.
03 MSG1F PIC X.
03 FILLER REDEFINES MSG1F.
05 MSG1A PIC X.
03 FILLER PIC X(2).
03 MSG1I PIC X(79).
03 DUMMY1L PIC S9(4) COMP.
03 DUMMY1F PIC X.
03 FILLER REDEFINES DUMMY1F.
05 DUMMY1A PIC X.
03 FILLER PIC X(2).
03 DUMMY1I PIC X(1).

* Output Data For Map MNTMAP1
01 MNTMAP1O REDEFINES MNTMAP1I.
03 FILLER PIC X(12).
03 FILLER PIC X(3).
03 TRANID1C PIC X.
03 TRANID1H PIC X.
03 TRANID1O PIC X(4).
03 FILLER PIC X(3).
03 CUSTNO1C PIC X.
03 CUSTNO1H PIC X.
03 CUSTNO1O PIC X(6).
03 FILLER PIC X(3).
03 ACTIONC PIC X.
03 ACTIONH PIC X.
03 ACTIONO PIC X(1).
03 FILLER PIC X(3).
03 MSG1C PIC X.
03 MSG1H PIC X.
03 MSG1O PIC X(79).
03 FILLER PIC X(3).
03 DUMMY1C PIC X.
03 DUMMY1H PIC X.
03 DUMMY1O PIC X(1).

* Input Data For Map MNTMAP2
01 MNTMAP2I.
03 FILLER PIC X(12).
03 TRANID2L PIC S9(4) COMP.
03 TRANID2F PIC X.
03 FILLER REDEFINES TRANID2F.
05 TRANID2A PIC X.
03 FILLER PIC X(2).
03 TRANID2I PIC X(4).
03 INSTR2L PIC S9(4) COMP.
03 INSTR2F PIC X.
03 FILLER REDEFINES INSTR2F.
05 INSTR2A PIC X.
03 FILLER PIC X(2).
03 INSTR2I PIC X(79).
03 CUSTNO2L PIC S9(4) COMP.
03 CUSTNO2F PIC X.
03 FILLER REDEFINES CUSTNO2F.
05 CUSTNO2A PIC X.
03 FILLER PIC X(2).
03 CUSTNO2I PIC X(6).
03 LNAMEL PIC S9(4) COMP.
03 LNAMEF PIC X.
03 FILLER REDEFINES LNAMEF.
05 LNAMEA PIC X.
03 FILLER PIC X(2).
03 LNAMEI PIC X(30).
03 FNAMEL PIC S9(4) COMP.
03 FNAMEF PIC X.
03 FILLER REDEFINES FNAMEF.
05 FNAMEA PIC X.
03 FILLER PIC X(2).
03 FNAMEI PIC X(20).
03 ADDRL PIC S9(4) COMP.
03 ADDRF PIC X.
03 FILLER REDEFINES ADDRF.
05 ADDRA PIC X.
03 FILLER PIC X(2).
03 ADDRI PIC X(30).
03 CITYL PIC S9(4) COMP.
03 CITYF PIC X.
03 FILLER REDEFINES CITYF.
05 CITYA PIC X.
03 FILLER PIC X(2).
03 CITYI PIC X(20).
03 STATEL PIC S9(4) COMP.
03 STATEF PIC X.
03 FILLER REDEFINES STATEF.
05 STATEA PIC X.
03 FILLER PIC X(2).
03 STATEI PIC X(2).
03 ZIPCODEL PIC S9(4) COMP.
03 ZIPCODEF PIC X.
03 FILLER REDEFINES ZIPCODEF.
05 ZIPCODEA PIC X.
03 FILLER PIC X(2).
03 ZIPCODEI PIC X(10).
03 MSG2L PIC S9(4) COMP.
03 MSG2F PIC X.
03 FILLER REDEFINES MSG2F.
05 MSG2A PIC X.
03 FILLER PIC X(2).
03 MSG2I PIC X(79).
03 DUMMY2L PIC S9(4) COMP.
03 DUMMY2F PIC X.
03 FILLER REDEFINES DUMMY2F.
05 DUMMY2A PIC X.
03 FILLER PIC X(2).
03 DUMMY2I PIC X(1).

* Output Data For Map MNTMAP2
01 MNTMAP2O REDEFINES MNTMAP2I.
03 FILLER PIC X(12).
03 FILLER PIC X(3).
03 TRANID2C PIC X.
03 TRANID2H PIC X.
03 TRANID2O PIC X(4).
03 FILLER PIC X(3).
03 INSTR2C PIC X.
03 INSTR2H PIC X.
03 INSTR2O PIC X(79).
03 FILLER PIC X(3).
03 CUSTNO2C PIC X.
03 CUSTNO2H PIC X.
03 CUSTNO2O PIC X(6).
03 FILLER PIC X(3).
03 LNAMEC PIC X.
03 LNAMEH PIC X.
03 LNAMEO PIC X(30).
03 FILLER PIC X(3).
03 FNAMEC PIC X.
03 FNAMEH PIC X.
03 FNAMEO PIC X(20).
03 FILLER PIC X(3).
03 ADDRC PIC X.
03 ADDRH PIC X.
03 ADDRO PIC X(30).
03 FILLER PIC X(3).
03 CITYC PIC X.
03 CITYH PIC X.
03 CITYO PIC X(20).
03 FILLER PIC X(3).
03 STATEC PIC X.
03 STATEH PIC X.
03 STATEO PIC X(2).
03 FILLER PIC X(3).
03 ZIPCODEC PIC X.
03 ZIPCODEH PIC X.
03 ZIPCODEO PIC X(10).
03 FILLER PIC X(3).
03 MSG2C PIC X.
03 MSG2H PIC X.
03 MSG2O PIC X(79).
03 FILLER PIC X(3).
03 DUMMY2C PIC X.
03 DUMMY2H PIC X.
03 DUMMY2O PIC X(1).


+ 2
- 0
it/it-projects/plugins/project/lib/c/mylib.h View File

@@ -0,0 +1,2 @@
#define ADD(X, Y) X + Y


+ 30
- 0
it/it-projects/plugins/project/pom.xml View File

@@ -0,0 +1,30 @@
<!--

Maven is used only to build project when Java files are changed. The generated
classes are stored in Git.
Sources are analyzed with sonar-runner.

-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonarsource.it-all-lang</groupId>
<artifactId>it-all-lang</artifactId>
<version>1.0-SNAPSHOT</version>
<name>All Languages</name>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/java</sourceDirectory>
<testSourceDirectory>test/java</testSourceDirectory>
</build>
</project>

+ 40
- 0
it/it-projects/plugins/project/sonar-project.properties View File

@@ -0,0 +1,40 @@
sonar.projectKey=all-langs
sonar.projectName=All Languages
sonar.projectVersion=1.0-SNAPSHOT

sonar.encoding=UTF-8
sonar.sources=.
sonar.inclusions=src/**,ext/**
# PLI temporarily disabled as it does not support multi-language configuration. It still requires
# the property sonar.language to be set to 'pli'.
sonar.exclusions=src/pli/**
sonar.test.inclusions=test/**

# C
sonar.cfamily.library.directories=lib/c

# Cobol
sonar.cobol.copy.directories=ext/cobol/copybooks
sonar.cobol.file.suffixes=cbl,cpy
sonar.cobol.copy.suffixes=cpy

# Java
sonar.junit.reportsPath=reports/java/surefire-reports
sonar.jacoco.reportPath=reports/java/jacoco.exec
sonar.java.binaries=target/classes
sonar.java.test.binaries=target/test-classes

# JavaScript
sonar.javascript.lcov.reportPath=target/js/lcov.dat

# Flex
sonar.flex.cobertura.reportPath=reports/flex/coverage.xml

#PHP
# Reusing PHPUnit reports
sonar.php.coverage.reportPath=target/php/phpunit.coverage.xml
sonar.php.tests.reportPath=target/php/phpunit.xml

#PLI - temporarily disabled (see exclusions)
sonar.pli.marginLeft=2
sonar.pli.marginRight=0

+ 147
- 0
it/it-projects/plugins/project/src/abap/ZBCMKZ17.abap View File

@@ -0,0 +1,147 @@
REPORT ZBCMKZ17.
*----------------------------------------------------------------------*
* Description: Report and Transaction Starter *
* It shows an individual list of reports/Trans. to start*
* *
* Authorization: S_PROGRAM, Reports starten *
* *
* Class: Utility *
* *
* Customizing: Needs Customer Table: ZBCMKZ1 *
* Field: Key Type Length Descr. *
* ZBCMKZ1-BNAME X CHAR C 12 User name *
* ZBCMKZ1-NAME X CHAR C 8 Report/Trans. code *
* ZBCMKZ1-NUMMER INT1 X 1 Priority level *
* *
* R/3 Release: 3.0d *
* *
* Programmer: Bence Toth *
* Date: 1997 April *
* *
*----------------------------------------------------------------------*
INCLUDE: <ICON>.
TABLES: ZBCMKZ1, TRDIR, TSTCT, TSTC.
DATA: BEGIN OF BTAB OCCURS 50, "Hilfstabelle fuer Textpool
CODE(82),
END OF BTAB.
DATA: BEGIN OF T OCCURS 100,
NUMMER LIKE ZBCMKZ1-NUMMER,
NAME LIKE TRDIR-NAME,
CODE(82),
END OF T.
DATA: FI(20).
DATA BEGIN OF BDCDATA OCCURS 100.
INCLUDE STRUCTURE BDCDATA.
DATA END OF BDCDATA.

DATA BEGIN OF MESSTAB OCCURS 10.
INCLUDE STRUCTURE BDCMSGCOLL.
DATA END OF MESSTAB.

DATA REPORT.
AUTHORITY-CHECK OBJECT 'S_PROGRAM'
ID 'P_GROUP' FIELD '*'
ID 'P_ACTION' FIELD '*'.
IF SY-SUBRC NE 0. EXIT. ENDIF.
WRITE: /2 'Er. Modus', 12 'Name', 22 'Text'.


DETAIL.
SKIP.
SELECT * FROM ZBCMKZ1 WHERE BNAME EQ SY-UNAME.
CHECK ZBCMKZ1-NAME+5(1) EQ ' '.
SELECT SINGLE * FROM TSTC WHERE TCODE EQ ZBCMKZ1-NAME.
CHECK SY-SUBRC EQ 0.
CLEAR TSTCT.
SELECT SINGLE * FROM TSTCT WHERE SPRSL EQ SY-LANGU AND
TCODE EQ ZBCMKZ1-NAME.
T-CODE = TSTCT-TTEXT.
MOVE-CORRESPONDING ZBCMKZ1 TO T.
APPEND T.
CLEAR T.
ENDSELECT.
SORT T BY NUMMER CODE.
REPORT = ' '.
PERFORM LIST USING REPORT.
SELECT * FROM ZBCMKZ1 WHERE BNAME EQ SY-UNAME.
CHECK ZBCMKZ1-NAME+5(1) NE ' '.
READ TEXTPOOL ZBCMKZ1-NAME INTO BTAB LANGUAGE SY-LANGU.
CHECK SY-SUBRC EQ 0.
LOOP AT BTAB.
IF BTAB-CODE(1) EQ 'R'.
EXIT.
ENDIF.
ENDLOOP.
MOVE BTAB-CODE+9(70) TO T-CODE.
MOVE-CORRESPONDING ZBCMKZ1 TO T.
APPEND T.
CLEAR T.
ENDSELECT.
SORT T BY NUMMER CODE.
REPORT = 'X'.
PERFORM LIST USING REPORT.

AT LINE-SELECTION.
CHECK NOT ( T-NAME IS INITIAL ).
GET CURSOR FIELD FI.
IF T-NAME+5(1) EQ ' '.
REPORT = ' '.
ELSE.
REPORT = 'X'.
ENDIF.
IF FI = 'ICON_EXECUTE_OBJECT'.
PERFORM PERO USING T-NAME REPORT.
ELSEIF REPORT EQ ' '.
* SELECT SINGLE * FROM TSTC WHERE TCODE EQ ZBCMKZ1-NAME.
* IF T+5(1) EQ ' '.
CALL TRANSACTION T-NAME.
ELSE.
SUBMIT (T-NAME) VIA SELECTION-SCREEN AND RETURN.
ENDIF.
CLEAR T-NAME.
*---------------------------------------------------------------------*
* FORM LIST *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
FORM LIST USING REPORT.
LOOP AT T.
IF REPORT = ' '.
WRITE: /5 ICON_EXECUTE_OBJECT AS ICON, T-NAME UNDER 'Name',
T-CODE UNDER 'Text'.
ELSE.
WRITE: / T-NAME UNDER 'Name', T-CODE UNDER 'Text'.
ENDIF.
HIDE T.
AT END OF NUMMER.
SKIP.
ENDAT.
ENDLOOP.
SKIP.
CLEAR T.
REFRESH T.
ENDFORM.
*---------------------------------------------------------------------*
* FORM PERO *
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
* --> T-NAME *
*---------------------------------------------------------------------*
FORM PERO USING T-NAME REPORT.
CHECK REPORT EQ ' '.
MOVE T-NAME TO T-NAME+2(4).
MOVE '/o' TO T-NAME+0(2).
BDCDATA-PROGRAM = 'SAPMS01J'.
BDCDATA-DYNPRO = '0310'.
BDCDATA-DYNBEGIN = 'X'.
APPEND BDCDATA.
CLEAR BDCDATA.
BDCDATA-FNAM = 'BDC_OKCODE'.
BDCDATA-FVAL = T-NAME.
APPEND BDCDATA.
CALL TRANSACTION 'SU50' USING BDCDATA MODE 'N'
MESSAGES INTO MESSTAB.
CLEAR BDCDATA.
REFRESH BDCDATA.
ENDFORM.

+ 194
- 0
it/it-projects/plugins/project/src/abap/ZZBGS106.abap View File

@@ -0,0 +1,194 @@
REPORT ZZBGS106 MESSAGE-ID Z1.
*----------------------------------------------------------------------*
* Description: Utillity used for downloading abap/4 source code and *
* text elements to the desktop using ws_download. *
* Is useful as backup or for transporting to another site.*
* You must run this program in foreground/online due to *
* the use of ws_download throug the SAPGUI. *
* *
* Implementing The program is client independent. *
* *
* Authoriza. No Authorization check. *
* *
* Submitting: Run by SA38, SE38. *
* *
* Parametre: You can use generic values when filling the parameters *
* except for the Path. *
* *
* Customizing: No need for customization. *
* *
* Change of You only need to do the syntax check at releasechanges. *
* release: *
* *
* R/3 Release: Developed and tested in R/3 Release: *
* 2.2F *
* 3.0D *
* *
* Programmer: Benny G. S�rensen, BGS-Consulting *
* Date: Nov 1996. *
* *
* Version 1
*-------------------------------Corrections----------------------------*
* Date Userid Correction Text *
* 11.11.1996 BGS :::::::::::::: Start of development *
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
* Tables *
*----------------------------------------------------------------------*
TABLES: TRDIR "Application Masterdata
.
*----------------------------------------------------------------------*
* Parameters *
*----------------------------------------------------------------------*
SELECT-OPTIONS: REPO FOR TRDIR-NAME.
PARAMETERS: PATH(60) TYPE C DEFAULT 'C:\SAP\'.

*----------------------------------------------------------------------*
* Work Variables and internal tables *
*----------------------------------------------------------------------*
DATA: BEGIN OF TABSOURCE OCCURS 10
,SOURCE(72) TYPE C
,END OF TABSOURCE.

DATA: BEGIN OF TABTEXT OCCURS 50
,TAB LIKE TEXTPOOL
,END OF TABTEXT.

DATA: BEGIN OF TABRDIR OCCURS 100
,RDIR LIKE TRDIR
,END OF TABRDIR.

DATA: FILENAME LIKE RLGRAP-FILENAME
,MODE TYPE C VALUE ' '
,RDIRROWS TYPE I
,SOURCEROWS TYPE I
,RC TYPE I
,LENGTH TYPE I
.
FIELD-SYMBOLS: <P> .

*----------------------------------------------------------------------*
* Constants *
*----------------------------------------------------------------------*
DATA: OK TYPE I VALUE 0
,FAIL TYPE I VALUE 1.

*----------------------------------------------------------------------*
* EVENT: validate users entries on the selection screen *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
DATA: I TYPE I.
DESCRIBE TABLE REPO LINES I.
IF I <= 0.
SET CURSOR FIELD REPO.
MESSAGE E065 WITH TEXT-101.
ENDIF.

*----------------------------------------------------------------------*
* EVENT: Start-Of-Selection *
*----------------------------------------------------------------------*
START-OF-SELECTION.
* Set slash at the end of path if not speciefied by user
CONDENSE PATH NO-GAPS.
LENGTH = STRLEN( PATH ) .
SUBTRACT 1 FROM LENGTH.
ASSIGN PATH+LENGTH(1) TO <P>.
IF <P> <> '\'.
ADD 1 TO LENGTH.
ASSIGN PATH+LENGTH TO <P>.
<P> = '\'.
ENDIF.

SELECT * FROM TRDIR INTO TABLE TABRDIR WHERE NAME IN REPO.
DESCRIBE TABLE TABRDIR LINES RDIRROWS.
CHECK RDIRROWS > 0.

* For every selected program:
LOOP AT TABRDIR.
MOVE TABRDIR TO TRDIR.
PERFORM DOWNLOAD_SOURCE USING RC.
CHECK RC = OK.
PERFORM DOWNLOAD_TEXTPOOL USING RC.
ENDLOOP.

*----------------------------------------------------------------------*
* FORM: Download_Sourcecode *
*----------------------------------------------------------------------*
FORM DOWNLOAD_SOURCE USING RC.
RC = FAIL.
CLEAR: TABSOURCE, FILENAME.
REFRESH: TABSOURCE.
READ REPORT TRDIR-NAME INTO TABSOURCE.
DESCRIBE TABLE TABSOURCE LINES SOURCEROWS.
CHECK SOURCEROWS > 0.

CALL FUNCTION 'STRING_CONCATENATE_3' "R. 2.2F
EXPORTING "R. 2.2F
STRING1 = PATH "R. 2.2F
STRING2 = TRDIR-NAME "R. 2.2F
STRING3 = '.aba' "R. 2.2F
IMPORTING "R. 2.2F
STRING = FILENAME "R. 2.2F
EXCEPTIONS "R. 2.2F
TOO_SMALL = 01. "R. 2.2F

* CONCATENATE PATH TRDIR-NAME '.ABA' INTO FILENAME. "R. 3.0D
CONDENSE FILENAME NO-GAPS.
PERFORM DOWNLOAD TABLES TABSOURCE USING FILENAME RC.

ENDFORM.

*----------------------------------------------------------------------*
* FORM: Download_Textpool *
*----------------------------------------------------------------------*
FORM DOWNLOAD_TEXTPOOL USING RC.
RC = FAIL.
CLEAR: TABTEXT, FILENAME.
REFRESH: TABTEXT.
READ TEXTPOOL TRDIR-NAME INTO TABTEXT LANGUAGE SY-LANGU.
DESCRIBE TABLE TABTEXT LINES SOURCEROWS.
CHECK SOURCEROWS > 0.

CALL FUNCTION 'STRING_CONCATENATE_3' "R. 2.2F
EXPORTING "R. 2.2F
STRING1 = PATH "R. 2.2F
STRING2 = TRDIR-NAME "R. 2.2F
STRING3 = '.TXT' "R. 2.2F
IMPORTING "R. 2.2F
STRING = FILENAME "R. 2.2F
EXCEPTIONS "R. 2.2F
TOO_SMALL = 01. "R. 2.2F

* CONCATENATE PATH TRDIR-NAME '.TXT' INTO FILENAME. "R. 3.0x
CONDENSE FILENAME NO-GAPS.
PERFORM DOWNLOAD TABLES TABTEXT USING FILENAME RC.

ENDFORM.

*----------------------------------------------------------------------*
* FORM: Download *
*----------------------------------------------------------------------*
FORM DOWNLOAD TABLES TABDATA USING FILENAME RC.

RC = FAIL.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = FILENAME
FILETYPE = 'ASC'
MODE = MODE
TABLES
DATA_TAB = TABDATA
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TABLE_WIDTH = 4
INVALID_TYPE = 5
NO_BATCH = 6
UNKNOWN_ERROR = 7.
IF SY-SUBRC <> OK.
WRITE:/ SY-SUBRC, TEXT-100.
ENDIF.
RC = SY-SUBRC.

ENDFORM.

+ 19
- 0
it/it-projects/plugins/project/src/c/main.c View File

@@ -0,0 +1,19 @@
#include <stdio.h> /* NOK, according to the MISRA C 2004 20.9 rule, stdio.h must not be used in embedded system's production code */

#include <mylib.h>

/*
* Compile & run from current folder:
* gcc -Wall -pedantic -std=c99 -I../lib -o main main.c && ./main
*/

int main(void) {
int x = ADD(40, 2);

if (x != 42)
{ /* NOK, empty code blocks generate violations */
}

// print something
printf("40 + 2 = %d\n", x);
}

+ 581
- 0
it/it-projects/plugins/project/src/cobol/Custmnt2.cbl View File

@@ -0,0 +1,581 @@
IDENTIFICATION DIVISION.
*
PROGRAM-ID. CUSTMNT2.
*
ENVIRONMENT DIVISION.
*
DATA DIVISION.
*
WORKING-STORAGE SECTION.
*
01 SWITCHES.
*
05 VALID-DATA-SW PIC X(01) VALUE 'Y'.
88 VALID-DATA VALUE 'Y'.
*
01 FLAGS.
*
05 SEND-FLAG PIC X(01).
88 SEND-ERASE VALUE '1'.
88 SEND-ERASE-ALARM VALUE '2'.
88 SEND-DATAONLY VALUE '3'.
88 SEND-DATAONLY-ALARM VALUE '4'.
*
01 WORK-FIELDS.
*
05 RESPONSE-CODE PIC S9(08) COMP.
*
01 USER-INSTRUCTIONS.
*
05 ADD-INSTRUCTION PIC X(79) VALUE
'Type information for new customer. Then Press Enter.'.
05 CHANGE-INSTRUCTION PIC X(79) VALUE
'Type changes. Then press Enter.'.
05 DELETE-INSTRUCTION PIC X(79) VALUE
'Press Enter to delete this customer or press F12 to canc
- 'el.'.
*
01 COMMUNICATION-AREA.
*
05 CA-CONTEXT-FLAG PIC X(01).
88 PROCESS-KEY-MAP VALUE '1'.
88 PROCESS-ADD-CUSTOMER VALUE '2'.
88 PROCESS-CHANGE-CUSTOMER VALUE '3'.
88 PROCESS-DELETE-CUSTOMER VALUE '4'.
05 CA-CUSTOMER-RECORD.
10 CA-CUSTOMER-NUMBER PIC X(06).
10 FILLER PIC X(112).
*
COPY CUSTMAS.
*
COPY MNTSET2.
*
COPY DFHAID.
*
COPY ATTR.
*
COPY ERRPARM.
*
LINKAGE SECTION.
*
01 DFHCOMMAREA PIC X(119).
*
PROCEDURE DIVISION.
*
0000-PROCESS-CUSTOMER-MAINT.
*
IF EIBCALEN > ZERO
MOVE DFHCOMMAREA TO COMMUNICATION-AREA
END-IF.
*
EVALUATE TRUE
*
WHEN EIBCALEN = ZERO
MOVE LOW-VALUE TO MNTMAP1O
MOVE -1 TO CUSTNO1L
SET SEND-ERASE TO TRUE
PERFORM 1500-SEND-KEY-MAP
SET PROCESS-KEY-MAP TO TRUE
*
WHEN EIBAID = DFHPF3
EXEC CICS
XCTL PROGRAM('INVMENU')
END-EXEC
*
WHEN EIBAID = DFHPF12
IF PROCESS-KEY-MAP
EXEC CICS
XCTL PROGRAM('INVMENU')
END-EXEC
ELSE
MOVE LOW-VALUE TO MNTMAP1O
MOVE -1 TO CUSTNO1L
SET SEND-ERASE TO TRUE
PERFORM 1500-SEND-KEY-MAP
SET PROCESS-KEY-MAP TO TRUE
END-IF
*
WHEN EIBAID = DFHCLEAR
IF PROCESS-KEY-MAP
MOVE LOW-VALUE TO MNTMAP1O
MOVE -1 TO CUSTNO1L
SET SEND-ERASE TO TRUE
PERFORM 1500-SEND-KEY-MAP
ELSE
MOVE LOW-VALUE TO MNTMAP2O
MOVE CA-CUSTOMER-NUMBER TO CUSTNO2O
EVALUATE TRUE
WHEN PROCESS-ADD-CUSTOMER
MOVE ADD-INSTRUCTION TO INSTR2O
WHEN PROCESS-CHANGE-CUSTOMER
MOVE CHANGE-INSTRUCTION TO INSTR2O
WHEN PROCESS-DELETE-CUSTOMER
MOVE DELETE-INSTRUCTION TO INSTR2O
END-EVALUATE
MOVE -1 TO LNAMEL
SET SEND-ERASE TO TRUE
PERFORM 1400-SEND-DATA-MAP
END-IF
*
WHEN EIBAID = DFHPA1 OR DFHPA2 OR DFHPA3
CONTINUE
*
WHEN EIBAID = DFHENTER
EVALUATE TRUE
WHEN PROCESS-KEY-MAP
PERFORM 1000-PROCESS-KEY-MAP
WHEN PROCESS-ADD-CUSTOMER
PERFORM 2000-PROCESS-ADD-CUSTOMER
WHEN PROCESS-CHANGE-CUSTOMER
PERFORM 3000-PROCESS-CHANGE-CUSTOMER
WHEN PROCESS-DELETE-CUSTOMER
PERFORM 4000-PROCESS-DELETE-CUSTOMER
END-EVALUATE
*
WHEN OTHER
IF PROCESS-KEY-MAP
MOVE LOW-VALUE TO MNTMAP1O
MOVE 'That key is unassigned.' TO MSG1O
MOVE -1 TO CUSTNO1L
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM 1500-SEND-KEY-MAP
ELSE
MOVE LOW-VALUE TO MNTMAP2O
MOVE 'That key is unassigned.' TO MSG2O
MOVE -1 TO LNAMEL
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM 1400-SEND-DATA-MAP
END-IF
*
END-EVALUATE.

EXEC CICS
RETURN TRANSID('MNT2')
COMMAREA(COMMUNICATION-AREA)
END-EXEC.
*
1000-PROCESS-KEY-MAP.
*
PERFORM 1100-RECEIVE-KEY-MAP.
PERFORM 1200-EDIT-KEY-DATA.
IF VALID-DATA
IF NOT PROCESS-DELETE-CUSTOMER
INSPECT CUSTOMER-MASTER-RECORD
REPLACING ALL SPACE BY '_'
END-IF
MOVE CUSTNO1I TO CUSTNO2O
MOVE CM-LAST-NAME TO LNAMEO
MOVE CM-FIRST-NAME TO FNAMEO
MOVE CM-ADDRESS TO ADDRO
MOVE CM-CITY TO CITYO
MOVE CM-STATE TO STATEO
MOVE CM-ZIP-CODE TO ZIPCODEO
MOVE -1 TO LNAMEL
SET SEND-ERASE TO TRUE
PERFORM 1400-SEND-DATA-MAP
ELSE
MOVE LOW-VALUE TO CUSTNO1O
ACTIONO
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM 1500-SEND-KEY-MAP
END-IF.
*
1100-RECEIVE-KEY-MAP.
*
EXEC CICS
RECEIVE MAP('MNTMAP1')
MAPSET('MNTSET2')
INTO(MNTMAP1I)
END-EXEC.
*
INSPECT MNTMAP1I
REPLACING ALL '_' BY SPACE.
*
1200-EDIT-KEY-DATA.
*
MOVE ATTR-NO-HIGHLIGHT TO ACTIONH
CUSTNO1H.
*
IF ACTIONI NOT = '1' AND '2' AND '3' AND '4' AND '5'
MOVE ATTR-REVERSE TO ACTIONH
MOVE -1 TO ACTIONL
MOVE 'Action must be 1, 2, or 3.' TO MSG1O
MOVE 'N' TO VALID-DATA-SW
END-IF.
*
IF CUSTNO1L = ZERO
OR CUSTNO1I = SPACE
MOVE ATTR-REVERSE TO CUSTNO1H
MOVE -1 TO CUSTNO1L
MOVE 'You must enter a customer number.' TO MSG1O
MOVE 'N' TO VALID-DATA-SW
END-IF.
*
IF VALID-DATA
MOVE LOW-VALUE TO MNTMAP2O
EVALUATE ACTIONI
WHEN '1'
PERFORM 1300-READ-CUSTOMER-RECORD
IF RESPONSE-CODE = DFHRESP(NOTFND)
MOVE ADD-INSTRUCTION TO INSTR2O
SET PROCESS-ADD-CUSTOMER TO TRUE
MOVE SPACE TO CUSTOMER-MASTER-RECORD
ELSE
IF RESPONSE-CODE = DFHRESP(NORMAL)
MOVE 'That customer already exists.'
TO MSG1O
MOVE 'N' TO VALID-DATA-SW
END-IF
END-IF
WHEN '2'
PERFORM 1300-READ-CUSTOMER-RECORD
IF RESPONSE-CODE = DFHRESP(NORMAL)
MOVE CUSTOMER-MASTER-RECORD TO
CA-CUSTOMER-RECORD
MOVE CHANGE-INSTRUCTION TO INSTR2O
SET PROCESS-CHANGE-CUSTOMER TO TRUE
ELSE
IF RESPONSE-CODE = DFHRESP(NOTFND)
MOVE 'That customer does not exist.' TO
MSG1O
MOVE 'N' TO VALID-DATA-SW
END-IF
END-IF
WHEN '3'
PERFORM 1300-READ-CUSTOMER-RECORD
IF RESPONSE-CODE = DFHRESP(NORMAL)
MOVE CUSTOMER-MASTER-RECORD TO
CA-CUSTOMER-RECORD
MOVE DELETE-INSTRUCTION TO INSTR2O
SET PROCESS-DELETE-CUSTOMER TO TRUE
MOVE ATTR-PROT TO LNAMEA
FNAMEA
ADDRA
CITYA
STATEA
ZIPCODEA
ELSE
IF RESPONSE-CODE = DFHRESP(NOTFND)
MOVE 'That customer does not exist.' TO
MSG1O
MOVE 'N' TO VALID-DATA-SW
END-IF
END-IF
END-EVALUATE.
*
1300-READ-CUSTOMER-RECORD.
*
EXEC CICS
READ FILE('CUSTMAS')
INTO(CUSTOMER-MASTER-RECORD)
RIDFLD(CUSTNO1I)
RESP(RESPONSE-CODE)
END-EXEC.
*
IF RESPONSE-CODE NOT = DFHRESP(NORMAL)
AND RESPONSE-CODE NOT = DFHRESP(NOTFND)
PERFORM 9999-TERMINATE-PROGRAM
END-IF.
*
1400-SEND-DATA-MAP.
*
MOVE 'MNT2' TO TRANID2O.
*
EVALUATE TRUE
WHEN SEND-ERASE
EXEC CICS
SEND MAP('MNTMAP2')
MAPSET('MNTSET2')
FROM(MNTMAP2O)
ERASE
CURSOR
END-EXEC
WHEN SEND-DATAONLY-ALARM
EXEC CICS
SEND MAP('MNTMAP2')
MAPSET('MNTSET2')
FROM(MNTMAP2O)
DATAONLY
ALARM
CURSOR
END-EXEC
END-EVALUATE.
*
1500-SEND-KEY-MAP.
*
MOVE 'MNT2' TO TRANID1O.
*
EVALUATE TRUE
WHEN SEND-ERASE
EXEC CICS
SEND MAP('MNTMAP1')
MAPSET('MNTSET2')
FROM(MNTMAP1O)
ERASE
CURSOR
END-EXEC
WHEN SEND-ERASE-ALARM
EXEC CICS
SEND MAP('MNTMAP1')
MAPSET('MNTSET2')
FROM(MNTMAP1O)
ERASE
ALARM
CURSOR
END-EXEC
WHEN SEND-DATAONLY-ALARM
EXEC CICS
SEND MAP('MNTMAP1')
MAPSET('MNTSET2')
FROM(MNTMAP1O)
DATAONLY
ALARM
CURSOR
END-EXEC
END-EVALUATE.
*
2000-PROCESS-ADD-CUSTOMER.
*
PERFORM 2100-RECEIVE-DATA-MAP.
PERFORM 2200-EDIT-CUSTOMER-DATA.
IF VALID-DATA
PERFORM 2300-WRITE-CUSTOMER-RECORD
IF RESPONSE-CODE = DFHRESP(NORMAL)
MOVE 'Customer record added.' TO MSG1O
SET SEND-ERASE TO TRUE
ELSE
IF RESPONSE-CODE = DFHRESP(DUPREC)
MOVE 'Another user has added a record with that c
- 'ustomer number.' TO MSG1O
SET SEND-ERASE-ALARM TO TRUE
END-IF
END-IF
MOVE -1 TO CUSTNO1L
PERFORM 1500-SEND-KEY-MAP
SET PROCESS-KEY-MAP TO TRUE
ELSE
MOVE LOW-VALUE TO LNAMEO
FNAMEO
ADDRO
CITYO
STATEO
ZIPCODEO
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM 1400-SEND-DATA-MAP
END-IF.
*
2100-RECEIVE-DATA-MAP.
*
EXEC CICS
RECEIVE MAP('MNTMAP2')
MAPSET('MNTSET2')
INTO(MNTMAP2I)
END-EXEC.
*
INSPECT MNTMAP2I
REPLACING ALL '_' BY SPACE.
*
2200-EDIT-CUSTOMER-DATA.
*
MOVE ATTR-NO-HIGHLIGHT TO ZIPCODEH
STATEH
CITYH
ADDRH
FNAMEH
LNAMEH.

IF ZIPCODEI = SPACE
OR ZIPCODEL = ZERO
MOVE ATTR-REVERSE TO ZIPCODEH
MOVE -1 TO ZIPCODEL
MOVE 'You must enter a zip code.' TO MSG2O
MOVE 'N' TO VALID-DATA-SW
END-IF.

IF STATEI = SPACE
OR STATEL = ZERO
MOVE ATTR-REVERSE TO STATEH
MOVE -1 TO STATEL
MOVE 'You must enter a state.' TO MSG2O
MOVE 'N' TO VALID-DATA-SW
END-IF.

IF CITYI = SPACE
OR CITYL = ZERO
MOVE ATTR-REVERSE TO CITYH
MOVE -1 TO CITYL
MOVE 'You must enter a city.' TO MSG2O
MOVE 'N' TO VALID-DATA-SW
END-IF.

IF ADDRI = SPACE
OR ADDRL = ZERO
MOVE ATTR-REVERSE TO ADDRH
MOVE -1 TO ADDRL
MOVE 'You must enter an address.' TO MSG2O
MOVE 'N' TO VALID-DATA-SW
END-IF.

IF FNAMEI = SPACE
OR FNAMEL = ZERO
MOVE ATTR-REVERSE TO FNAMEH
MOVE -1 TO FNAMEL
MOVE 'You must enter a first name.' TO MSG2O
MOVE 'N' TO VALID-DATA-SW
END-IF.

IF LNAMEI = SPACE
OR LNAMEL = ZERO
MOVE ATTR-REVERSE TO LNAMEH
MOVE -1 TO LNAMEL
MOVE 'You must enter a last name.' TO MSG2O
MOVE 'N' TO VALID-DATA-SW
END-IF.
*
2300-WRITE-CUSTOMER-RECORD.
*
MOVE CUSTNO2I TO CM-CUSTOMER-NUMBER.
MOVE LNAMEI TO CM-LAST-NAME.
MOVE FNAMEI TO CM-FIRST-NAME.
MOVE ADDRI TO CM-ADDRESS.
MOVE CITYI TO CM-CITY.
MOVE STATEI TO CM-STATE.
MOVE ZIPCODEI TO CM-ZIP-CODE.
*
EXEC CICS
WRITE FILE('CUSTMAS')
FROM(CUSTOMER-MASTER-RECORD)
RIDFLD(CM-CUSTOMER-NUMBER)
RESP(RESPONSE-CODE)
END-EXEC.
*
IF RESPONSE-CODE NOT = DFHRESP(NORMAL)
AND RESPONSE-CODE NOT = DFHRESP(DUPREC)
PERFORM 9999-TERMINATE-PROGRAM
END-IF.
*
3000-PROCESS-CHANGE-CUSTOMER.
*
PERFORM 2100-RECEIVE-DATA-MAP.
PERFORM 2200-EDIT-CUSTOMER-DATA.
IF VALID-DATA
MOVE CUSTNO2I TO CM-CUSTOMER-NUMBER
PERFORM 3100-READ-CUSTOMER-FOR-UPDATE
IF RESPONSE-CODE = DFHRESP(NORMAL)
IF CUSTOMER-MASTER-RECORD = CA-CUSTOMER-RECORD
* Introduce extra nested if as an example of rule violation
IF VALID-DATA
IF RESPONSE-CODE = DFHRESP(NORMAL)
PERFORM 3200-REWRITE-CUSTOMER-RECORD
MOVE 'Customer record updated.' TO MSG1O
SET SEND-ERASE TO TRUE
END-IF
END-IF
ELSE
MOVE 'Another user has updated the record. Try a
- 'gain.' TO MSG1O
SET SEND-ERASE-ALARM TO TRUE
END-IF
ELSE
IF RESPONSE-CODE = DFHRESP(NOTFND)
MOVE 'Another user has deleted the record.' TO
MSG1O
SET SEND-ERASE-ALARM TO TRUE
END-IF
END-IF
MOVE -1 TO CUSTNO1L
PERFORM 1500-SEND-KEY-MAP
SET PROCESS-KEY-MAP TO TRUE
ELSE
MOVE LOW-VALUE TO LNAMEO
FNAMEO
ADDRO
CITYO
STATEO
ZIPCODEO
SET SEND-DATAONLY-ALARM TO TRUE
PERFORM 1400-SEND-DATA-MAP
END-IF.
*
3100-READ-CUSTOMER-FOR-UPDATE.
*
EXEC CICS
READ FILE('CUSTMAS')
INTO(CUSTOMER-MASTER-RECORD)
RIDFLD(CM-CUSTOMER-NUMBER)
UPDATE
RESP(RESPONSE-CODE)
END-EXEC.
*
IF RESPONSE-CODE NOT = DFHRESP(NORMAL)
AND RESPONSE-CODE NOT = DFHRESP(NOTFND)
PERFORM 9999-TERMINATE-PROGRAM
END-IF.
*
3200-REWRITE-CUSTOMER-RECORD.
*
MOVE LNAMEI TO CM-LAST-NAME.
MOVE FNAMEI TO CM-FIRST-NAME.
MOVE ADDRI TO CM-ADDRESS.
MOVE CITYI TO CM-CITY.
MOVE STATEI TO CM-STATE.
MOVE ZIPCODEI TO CM-ZIP-CODE.
*
EXEC CICS
REWRITE FILE('CUSTMAS')
FROM(CUSTOMER-MASTER-RECORD)
RESP(RESPONSE-CODE)
END-EXEC.
*
IF RESPONSE-CODE NOT = DFHRESP(NORMAL)
PERFORM 9999-TERMINATE-PROGRAM
END-IF.
*
4000-PROCESS-DELETE-CUSTOMER.
*
MOVE CA-CUSTOMER-NUMBER TO CM-CUSTOMER-NUMBER.
PERFORM 3100-READ-CUSTOMER-FOR-UPDATE.
IF RESPONSE-CODE = DFHRESP(NORMAL)
ALTER X TO PROCEED TO Y
IF CUSTOMER-MASTER-RECORD = CA-CUSTOMER-RECORD
PERFORM 4100-DELETE-CUSTOMER-RECORD
MOVE 'Customer deleted.' TO MSG1O
SET SEND-ERASE TO TRUE
ELSE
MOVE 'Another user has updated the record. Try again
- '.' TO MSG1O
SET SEND-ERASE-ALARM TO TRUE
END-IF
ELSE
IF RESPONSE-CODE = DFHRESP(NOTFND)
MOVE 'Another user has deleted the record.' TO
MSG1O
SET SEND-ERASE-ALARM TO TRUE
END-IF
END-IF.
MOVE -1 TO CUSTNO1L.
PERFORM 1500-SEND-KEY-MAP.
SET PROCESS-KEY-MAP TO TRUE.
*
4100-DELETE-CUSTOMER-RECORD.
* TODO Some comment
EXEC CICS
DELETE FILE('CUSTMAS')
RESP(RESPONSE-CODE)
END-EXEC.
*
IF RESPONSE-CODE NOT = DFHRESP(NORMAL)
PERFORM 9999-TERMINATE-PROGRAM
END-IF.
*
9999-TERMINATE-PROGRAM.
*
MOVE EIBRESP TO ERR-RESP.
MOVE EIBRESP2 TO ERR-RESP2.
MOVE EIBTRNID TO ERR-TRNID.
MOVE EIBRSRCE TO ERR-RSRCE.
*
EXEC CICS
XCTL PROGRAM('SYSERR')
COMMAREA(ERROR-PARAMETERS)
END-EXEC.

+ 17508
- 0
it/it-projects/plugins/project/src/cobol/TC4E3H0.CBL
File diff suppressed because it is too large
View File


+ 51
- 0
it/it-projects/plugins/project/src/cpp/BiggestUnInt.cc View File

@@ -0,0 +1,51 @@
// BiggestUnInt2.cc
// usage:
// BiggestUnInt2 <starting number> (optional argument, default is 1)
// example:
// BiggestUnInt2 4194305
// features:

#include <iostream>
#include <cstdlib>

using namespace std;

void bitsout( unsigned int n );

int main(int argc, char* argv[])
{
int N=0;
unsigned int i=1 , oldi , j ;
if(argc>1) {
sscanf( argv[1], "%u", &i ) ; // starting value
}
cout << "#\ti \ti+(i-1)\t2i\n" ;
cout << "#\t#### \t#######\t###\n" ;
do {
oldi = i ;
j = i-1 ;
j += i ; // this sets j = 2i-1 (we hope)
i *= 2 ; // this doubles i (we hope)
cout << N << ":\t" << oldi << "\t" << j << "\t" << i << "\t";
bitsout(i);
cout << endl ;
N++;
} while ( j+1==i && i!=0 ) ; // keep going until something odd happens
// (Under normal arithmetic,
// we always expect A: j+1 to equal i, and
// we always expect B: i not to be 0
// we keep going while _both_ A _and_ B are true.)
// ( '&&' means "_and_" )
}

void bitsout( unsigned int m )
{
int lastbit ;
unsigned int two_to_power_i ;
for ( int i = 31 ; i >= 0 ; i -- ) {
two_to_power_i = (1<<i) ;
lastbit = ( two_to_power_i & m ) == 0 ? 0 : 1 ;
cout << lastbit ;
}
}

+ 8
- 0
it/it-projects/plugins/project/src/cpp/HelloWorld.cpp View File

@@ -0,0 +1,8 @@
using namespace std;

int main ()
{
// comment
cout << "Hello World!";
return 0;
}

+ 87
- 0
it/it-projects/plugins/project/src/cpp/RandDemo.cc View File

@@ -0,0 +1,87 @@
// RandDemo.cc
// features:
// * uses random() to get a random integer
// * gets interactive user input
// * uses ternary operator "q ? a : b"

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

#define ranf() \
((double)random()/(1.0+(double)RAND_MAX)) // Uniform from interval [0,1) */

int main()
{
int outcome, N=0, count_in=0 ;
double fraction_in ;
// Initialise random number generator with value of system time.
srandom(time(NULL));
// Get user input in correct range.
while(N<1)
{
cout << "Input the number of experiments: ";
cin >> N;
}
// Perform N experiments.
for(int n=1; n<=N; n++)
{
double x = ranf();
double y = ranf();
outcome = ( x*x + y*y > 1.0 ) ? 0 : 1 ;
if(outcome==1) count_in++;
cout << outcome << "\t" << x << "\t" << y << "\t"
<< count_in << "\t" << n << endl;
}
// Sample goto to raise a violation
goto L1;
//Sample switch with default
switch (bob)
{
case 1: {
cout << "1";
break;
}
case 2:
{
cout <<"2";
break;
}
default:
{
cout << "3";
}
}
//Sample switch without default
switch (bob)
{
case 1: {
cout << "1";
break;
}
case 2:
{
cout <<"2";
break;
}
}
//Integer variables must be converted (cast) for correct division
fraction_in = static_cast<double>(count_in)/N;

// Output results
cout << "# Proportion of outcomes 'in' "
<< fraction_in << endl;
// Output results
cout << "# pi-hat = "
<< 4.0 * fraction_in << endl;
return 0;
}

+ 70
- 0
it/it-projects/plugins/project/src/cpp/SimpleClass.cc View File

@@ -0,0 +1,70 @@
// DateClass.cc
// Program to demonstrate the definition of a simple class
// and member functions

#include <iostream>
using namespace std;


// Declaration of Date class
class Date {

public:
Date(int, int, int);
void set(int, int, int);
void print();

private:
int year;
int month;
int day;
};


int main()
{
// Declare today to be object of class Date
// Values are automatically intialised by calling constructor function
Date today(1,9,1999);

cout << "This program was written on ";
today.print();

cout << "This program was modified on ";
today.set(5,10,1999);
today.print();

return 0;
}

// Date constructor function definition
Date::Date(int d, int m, int y)
{
if(d>0 && d<31) day = d;
if(m>0 && m<13) month = m;
if(y>0) year =y;
}

// Date member function definitions
void Date::set(int d, int m, int y)
{
if(d>0) {
if (d<31){
if(m>0) {
if (m<13) {
if(y>0) {
year =y;
month = m;
day = d;
}
}
}
}
}
}

void Date::print()
{
cout << day << "-" << month << "-" << year << endl;
}


+ 18
- 0
it/it-projects/plugins/project/src/cpp/main.c View File

@@ -0,0 +1,18 @@
#include <stdio.h> /* NOK, according to the MISRA C 2004 20.9 rule, stdio.h must not be used in embedded system's production code */

#include <mylib.h>

/*
* Compile & run from current folder:
* gcc -Wall -pedantic -std=c99 -I../lib -o main main.c && ./main
*/
int main(void) {
int x = ADD(40, 2);
if (x != 42)
{ /* NOK, empty code blocks generate violations */
}

printf("40 + 2 = %d\n", x);
}

+ 89
- 0
it/it-projects/plugins/project/src/css/sample.css View File

@@ -0,0 +1,89 @@
.quality-gates-navigator .navigator-side {
display: table-cell;
vertical-align: top;
width: 250px;
min-width: 0;
}
.quality-gates-navigator .navigator-header {
margin-left: 0;
}
.quality-gates-navigator .navigator-header .spinner {
margin-top: 9px;
}
.quality-gates-navigator .navigator-actions {
height: 40px;
width: 230px;
margin: 10px;
padding: 0 10px;
}
.quality-gates-navigator .navigator-actions .navigator-header-title {
color: #444;
font-size: 13px;
font-weight: 700;
text-transform: uppercase;
}
.quality-gates-navigator .navigator-results {
width: 230px;
min-width: 0;
}
.quality-gates-navigator .navigator-details {
margin-left: 0;
}
.quality-gates-nav .navigator-results-list>li {
border-color: transparent;
}
.quality-gates-nav .navigator-results-list>li:hover:not(.active):not(.empty) {
background-color: #f3f3f3;
}
.quality-gates-nav .navigator-results-list>li.active {
border-color: #4B9FD5;
}
.quality-gates-nav .navigator-results-list>li.empty {
cursor: default;
}
.quality-gates-nav .navigator-results-list>li .line {
padding-top: 2px;
padding-bottom: 2px;
}
.quality-gates-nav .navigator-results-list>li .subtitle {
text-transform: lowercase;
}
.quality-gate-section+.quality-gate-section {
margin-top: 10px;
padding-top: 20px;
}
.quality-gate-section-empty+.quality-gate-section {
border-top: 1px solid #e6e6e6;
}
.quality-gate-section-name {
margin-bottom: 10px;
font-weight: 700;
text-transform: uppercase;
}
.quality-gate-introduction {
margin-bottom: 20px;
}
.quality-gate-new-condition {
margin-bottom: 10px;
}
.quality-gate-condition-actions {
position: relative;
}
.quality-gate-default-message {
padding: 6px 5px;
border: 1px solid #ddd;
background-color: #efefef;
}
.quality-gate-conditions-wrap {
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
}
.quality-gate-conditions .deprecated {
color: #777;
text-transform: lowercase;
font-variant: small-caps;
}
.quality-gate-conditions tbody {
border-left: none!important;
border-right: none!important;
}

+ 14
- 0
it/it-projects/plugins/project/src/flex/Circle.as View File

@@ -0,0 +1,14 @@
package {

public class Circle {
public var diameter:int = 0;

function Circle (d:int) {
if (d == 0) {
this.diameter = -1;
} else {
this.diameter = d;
}
}
}
}

+ 12
- 0
it/it-projects/plugins/project/src/flex/HasIssues.as View File

@@ -0,0 +1,12 @@
package {

public class HasIssues {

function HasIssues (d:int) {
if (d == 0) {
break
}
break
}
}
}

+ 10
- 0
it/it-projects/plugins/project/src/flex/UncoveredCircle.as View File

@@ -0,0 +1,10 @@
package {

public class UncoveredCircle {
public var diameter:int = 0;

function UncoveredCircle (d:int) {
this.diameter = d;
}
}
}

+ 7
- 0
it/it-projects/plugins/project/src/groovy/example/Greeting.groovy View File

@@ -0,0 +1,7 @@
package example

class Greeting {
def say() {
println 'Hello World'
}
}

+ 14
- 0
it/it-projects/plugins/project/src/groovy/innerclass/InnerClassExample.groovy View File

@@ -0,0 +1,14 @@
package innerclass

class InnerClassExample
{
def show() {
println 'Hello World'
new ExampleInnerClass().show()
}

class ExampleInnerClass {
def show() { println "Hello Inner"}
}

}

+ 15
- 0
it/it-projects/plugins/project/src/java/foo/Foo.java View File

@@ -0,0 +1,15 @@
package foo;

/**
* Foo class
*/
public class Foo {

public static int div(int a, int b) {
if (b == 0) {
throw new UnsupportedOperationException("Can't divide by zero!");
}
return a / b;
}

}

+ 17
- 0
it/it-projects/plugins/project/src/java/foo/Simplest.java View File

@@ -0,0 +1,17 @@
package foo;

/**
* Simple class
*/
public class Simplest {

public static int add(int a, int b) {
// introduce a variable that is not needed - just to get a violation
int result = a + b;

System.out.println("");

return result;
}

}

+ 7
- 0
it/it-projects/plugins/project/src/java/foo/Simplest2.java View File

@@ -0,0 +1,7 @@
package foo;

public class Simplest2 {

public static void foo() {}

}

+ 5
- 0
it/it-projects/plugins/project/src/java/foo/Simplest3.java View File

@@ -0,0 +1,5 @@
package foo;

public class Simplest3 {

}

+ 18
- 0
it/it-projects/plugins/project/src/js/HasIssues.js View File

@@ -0,0 +1,18 @@
// FIXME
alert("should not be used");

function strict() {
'use strict';
}

function pow(a, b) {
if(b == 0) {
return 0;
}
var x = a;
for (var i = 1; i<b; i++) {
//Dead store because the last return statement should return x instead of returning a
x = x * a;
}
return a;
}

+ 14
- 0
it/it-projects/plugins/project/src/js/Person.js View File

@@ -0,0 +1,14 @@

var Person = function(first, last, middle) {
this.first = first;
this.middle = middle;
this.last = last;
};

Person.prototype = {

whoAreYou : function() {
return this.first + (this.middle ? ' ' + this.middle: '') + ' ' + this.last;
}

};

+ 50
- 0
it/it-projects/plugins/project/src/js/com/company/Car.js View File

@@ -0,0 +1,50 @@
var Car = function(brand, model, year) {
this.brand = brand;
this.model = model;
this.year = year;
this.engineState = 'stopped';
this.messageToDriver = '';
};

Car.prototype = {

getFullName : function() {
return this.brand + ' ' + this.model + ' ' + 'Y: ' + this.year;
},

calculatePrice : function() {
if (this.year < 1990) {
return '$1500';
} else if (this.year > 2011) {
return '$30000';
} else {
return '$1500 - 30000';
}
},

startEngine : function() {
this.engineState = 'started';
return 'engine started';
},

stopEngine : function() {
this.engineState = 'stopped';
return 'engine stopped';
},

stopEngineWithCheck : function() {
if (this.engineState === 'started') {
this.engineState = 'stopped';
this.messageToDriver = 'all good. c u later';
return 'engine stopped';
} else {
this.messageToDriver = 'engine not started. what do you want me to do?';
return 'engine was not running';
}
},

tuneCar : function() {
this.year = '2011';
}

};

+ 24
- 0
it/it-projects/plugins/project/src/js/com/company/Truck.js View File

@@ -0,0 +1,24 @@
var Truck = function(brand, model, year) {
this.brand = brand;
this.model = model;
this.year = year;
this.engineState = 'stopped';
this.messageToDriver = '';
};

Truck.prototype = {

getFullName : function() {
return this.brand + ' ' + this.model + ' ' + 'Y: ' + this.year;
},

calculatePrice : function() {
if (this.year < 1990) {
return '$15000';
} else if (this.year > 2011) {
return '$300000';
} else {
return '$15000 - 300000';
}
}
};

+ 53
- 0
it/it-projects/plugins/project/src/js/com/company/Vehicle.js View File

@@ -0,0 +1,53 @@
/**
* This is copy/paste file from Car.js with couple methods removed
*
* Removed methods:
* - startEngine ()
* - stopEngine ()
*
*/
var Vehicle = function(brand, model, year) {
this.brand = brand;
this.model = model;
this.year = year;
this.engineState = 'stopped';
this.messageToDriver = '';
};


// single line comments line 1
// single line comments line 2
// single line comments line 3
// single line comments line 4
Vehicle.prototype = {

getFullName : function() {
return this.brand + ' ' + this.model + ' ' + 'Y: ' + this.year;
},

calculatePrice : function() {
if (this.year < 1990) {
return '$1500';
} else if (this.year > 2011) {
return '$30000';
} else {
return '$1500 - 30000';
}
},

stopEngineWithCheck : function() {
if (this.engineState === 'started') {
this.engineState = 'stopped';
this.messageToDriver = 'all good. c u later';
return 'engine stopped';
} else {
this.messageToDriver = 'engine not started. what do you want me to do?';
return 'engine was not running';
}
},

tuneCar : function() {
this.year = '2011';
}

};

+ 214
- 0
it/it-projects/plugins/project/src/php/Math.php View File

@@ -0,0 +1,214 @@
<?php
/**
* This file is part of phpUnderControl.
*
* Copyright (c) 2007-2009, Manuel Pichler <mapi@phpundercontrol.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Manuel Pichler nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package Example
* @author Manuel Pichler <mapi@phpundercontrol.org>
* @copyright 2007-2009 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version SVN: $Id: Math.php 4429 2009-01-04 15:39:45Z mapi $
* @link http://www.phpundercontrol.org/
*/
function add($v1 , $v2)
{
return ($v1 + $v2);
}

/**
* Simple math class.
*
* @package Example
* @author Manuel Pichler <mapi@phpundercontrol.org>
* @copyright 2007-2009 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: 0.5.0
* @link http://www.phpundercontrol.org/
*/
class PhpUnderControl_Example_Math
{
/**
* Adds the two given values.
*
* @param integer $v1 Value one.
* @param integer $v2 Value two.
*
* @return integer.
*/
public function add($v1 , $v2)
{
return ($v1 + $v2);
}

/**
* Subtract param two from param one
*
* @param integer $v1 Value one.
* @param integer $v2 Value two.
*
* @return integer.
*/
public function sub($v1, $v2)
{
return ($v1 - $v2);
}

/**
* Not tested method that should be visible with low coverage.
*/
public function div($v1, $v2)
{
$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
{
$v4 = 0;
for ($i = 0; $i < $v3; $i++)
{
$v4 += ($v2 * $i);
}
}
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));

$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);

$d = array($v1, $v2, $v3, $v4, $v5, $v6);

$v7 = 1;
for ($i = 0; $i < $v6; $i++)
{
shuffle( $d );
$v7 = $v7 + $i * end($d);
}

$v8 = $v7;
foreach ( $d as $x )
{
$v8 *= $x;
}
$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
{
$v4 = 0;
for ($i = 0; $i < $v3; $i++)
{
$v4 += ($v2 * $i);
}
}
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));

$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);

$d = array($v1, $v2, $v3, $v4, $v5, $v6);

$v7 = 1;
for ($i = 0; $i < $v6; $i++)
{
shuffle( $d );
$v7 = $v7 + $i * end($d);
}

$v8 = $v7;
foreach ( $d as $x )
{
$v8 *= $x;
}

return $v8;
}

/**
* Simple copy for cpd detection.
*/
public function complex($v1, $v2)
{
$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
{
$v4 = 0;
for ($i = 0; $i < $v3; $i++)
{
$v4 += ($v2 * $i);
}
}
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));

$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);

$d = array($v1, $v2, $v3, $v4, $v5, $v6);

$v7 = 1;
for ($i = 0; $i < $v6; $i++)
{
shuffle( $d );
$v7 = $v7 + $i * end( $d );
}

$v8 = $v7;
foreach ( $d as $x )
{
$v8 *= $x;
}
$v3 = $v1 / ($v2 + $v1);
if ($v3 > 14)
{
$v4 = 0;
for ($i = 0; $i < $v3; $i++)
{
$v4 += ($v2 * $i);
}
}
$v5 = ($v4 < $v3 ? ($v3 - $v4) : ($v4 - $v3));

$v6 = ($v1 * $v2 * $v3 * $v4 * $v5);

$d = array($v1, $v2, $v3, $v4, $v5, $v6);

$v7 = 1;
for ($i = 0; $i < $v6; $i++)
{
shuffle( $d );
$v7 = $v7 + $i * end($d);
}

$v8 = $v7;
foreach ( $d as $x )
{
$v8 *= $x;
}

return $v8;
}
}

+ 212
- 0
it/it-projects/plugins/project/src/pli/center.pli View File

@@ -0,0 +1,212 @@
/* Copyright (c) 1995 by R. A. Vowels, from "Introduction to PL/I, Algorithms, and */
/* Structured Programming". Permission is given to reproduce and to use these procedures */
/* as part of a program, and to include them as part of a larger work to be sold for profit. */
/* However, the user is not permitted to sell the procedures separately. Provided always */
/* that these procedures and this copyright notice are reproduced in full. */

DECLARE CENTERLEFT GENERIC
(CENTER_LEFT_2 WHEN (*, *),
CENTER_LEFT_3 WHEN (*, *, *) );
DECLARE CENTER GENERIC
(CENTER_LEFT_2 WHEN (*, *),
CENTER_LEFT_3 WHEN (*, *, *) );
DECLARE CENTERRIGHT GENERIC
(CENTER_RIGHT_2 WHEN (*, *),
CENTER_RIGHT_3 WHEN (*, *, *) );
DECLARE CENTRELEFT GENERIC
(CENTER_LEFT_2 WHEN (*, *),
CENTER_LEFT_3 WHEN (*, *, *) );
DECLARE CENTRERIGHT GENERIC
(CENTER_RIGHT_2 WHEN (*, *),
CENTER_RIGHT_3 WHEN (*, *, *) );
/* This procedure returns a string of length LEN, with STRING in the dead center, or one */
/* position to the left of dead center if it cannot be dead center. */
CENTER_LEFT_2:
PROCEDURE (STRING, LEN) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be centered; */
/* LEN = the length of the produced string in which STRING is to be */
/* centered. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;

DECLARE WORK CHARACTER (LEN);
DECLARE (K, L) FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

K = (LEN - L + 2)/2;

WORK = '';
SUBSTR (WORK, K, L) = STRING;
RETURN (WORK);
END CENTER_LEFT_2;

/* This procedure returns a string of length LEN, with STRING in the dead center, or one */
/* position to the left of dead center if it cannot be dead center. A specified fill */
/* character FILL extends STRING right and left. */
CENTER_LEFT_3:
PROCEDURE (STRING, LEN, FILL) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be centered; */
/* LEN = the length of the produced string in which STRING is to be */
/* centered. */
/* FILL = a fill character used to extend STRING at both ends. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;
DECLARE FILL CHARACTER (1);

DECLARE WORK CHARACTER (LEN);
DECLARE (K, L) FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

K = (LEN - L + 2)/2;

WORK = REPEAT (FILL, LEN-1);
SUBSTR (WORK, K, L) = STRING;
RETURN (WORK);
END CENTER_LEFT_3;

/* This procedure returns a string of length LEN, with STRING in the dead center, or one */
/* position to the right of dead center if it cannot be dead center. */
CENTER_RIGHT_2:
PROCEDURE (STRING, LEN) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be centered; */
/* LEN = the length of the produced string in which STRING is to be */
/* centered. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;

DECLARE WORK CHARACTER (LEN);
DECLARE (K, L) FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

K = (LEN - L + 3)/2;

WORK = '';
SUBSTR (WORK, K, L) = STRING;
RETURN (WORK);
END CENTER_RIGHT_2;

/* This procedure returns a string of length LEN, with STRING in the dead center, or one */
/* position to the right of dead center if it cannot be dead center. A specified fill */
/* character FILL extends STRING right and left. */
CENTER_RIGHT_3:
PROCEDURE (STRING, LEN, FILL) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be centered; */
/* LEN = the length of the produced string in which STRING is to be */
/* centered. */
/* FILL = a fill character used to extend STRING at both ends. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;
DECLARE FILL CHARACTER (1);

DECLARE WORK CHARACTER (LEN);
DECLARE (K, L) FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

K = (LEN - L + 3)/2;

WORK = REPEAT (FILL, LEN-1);
SUBSTR (WORK, K, L) = STRING;
RETURN (WORK);
END CENTER_RIGHT_3;

DECLARE LEFT GENERIC
(LEFT_blank WHEN (*,*),
LEFT_other WHEN (*,*,*) );

/* This procedure returns STRING in a string of length LEN, with blank characters padded on */
/* the right. */
LEFT_blank:
PROCEDURE (STRING, LEN) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be positioned left; */
/* LEN = the length of the produced string in which STRING is to be */
/* placed. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;

DECLARE WORK CHARACTER (LEN);
DECLARE L FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

WORK = '';
SUBSTR (WORK, 1, L) = STRING;
RETURN (WORK);
END LEFT_blank;

/* This procedure returns STRING in a string of length LEN, padded with the character */
/* FILL on the right. */
LEFT_other:
PROCEDURE (STRING, LEN, FILL) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be positioned left; */
/* LEN = the length of the produced string in which STRING is to be */
/* positioned left; */
/* FILL = the character to be used to fill out the finished string. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;
DECLARE FILL CHARACTER (1);

DECLARE WORK CHARACTER (LEN);
DECLARE L FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

WORK = STRING || REPEAT (FILL, LEN-L-1);
RETURN (WORK);
END LEFT_other;

DECLARE RIGHT GENERIC
(RIGHT_blank WHEN (*,*),
RIGHT_other WHEN (*,*,*) );

/* This procedure returns STRING right-adjusted in a string of length N, padded with blanks */
/* on the left. */
RIGHT_blank:
PROCEDURE (STRING, LEN) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be positioned right; */
/* LEN = the length of the produced string in which STRING is to be */
/* positioned right. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;

DECLARE WORK CHARACTER (LEN);
DECLARE L FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

WORK = '';
SUBSTR (WORK, LEN-L+1, L) = STRING;
RETURN (WORK);
END RIGHT_blank;

/* This procedure returns STRING right-adjusted in a string of length N, padded with the */
/* character FILL on the left. */
RIGHT_other:
PROCEDURE (STRING, LEN, FILL) RETURNS (CHARACTER(1000) VARYING);
/* INCOMING: STRING = the string to be positioned right; */
/* LEN = the length of the produced string in which STRING is to be */
/* positioned right; */
/* FILL = the character to be used to fill out the finished string. */
DECLARE STRING CHARACTER (*) VARYING;
DECLARE LEN FIXED BINARY;
DECLARE FILL CHARACTER (1);

DECLARE WORK CHARACTER (LEN);
DECLARE L FIXED BINARY;

L = LENGTH (STRING);
IF L >= LEN THEN RETURN (STRING);

WORK = REPEAT (FILL, LEN-L-1) || STRING;
RETURN (WORK);
END RIGHT_other;

+ 760
- 0
it/it-projects/plugins/project/src/pli/chess.pli View File

@@ -0,0 +1,760 @@
/* This is a chess program written in PL/I. */
/* The original was written in Fortran 90 by Dean Menezes. */
/* This translation by R. A. Vowels, 30 May 2008. */
/* Moves are input in this form: */
/* E2-E4 (start square, hyphen, end square). */

/* Sources: */

/* http://ai-depot.com/articles/minimax-explained/ */
/* http://www.aihorizon.com/essays/chessai/index.htm */
/* http://www.ascotti.org/programming/chess/Shannon%20-%20Programming
%20a%20computer%20for%20playing%20chess.pdf */

(SUBRG, SIZE, FOFL, STRINGRANGE, STRINGSIZE):
CHESS: PROCEDURE OPTIONS (MAIN, REORDER);
/* Global variables: */
/* level = current recursion level for calculation */
/* maxlevel = maximum recursion level */
/* score = current score (evaluation) */
/* besta, bestb, bestx, besty = holds best moves for each recursion level */
/* wcksflag, wcqsflag = flags to detemine castling abilities */
/* board = the 8x8 array to hold chessboard */
DECLARE ( MAXLEVEL VALUE ( 5) ) FIXED BINARY;
DECLARE ( LEVEL, SCORE, BESTA(0:7) ) FIXED BINARY (31);
DECLARE ( BESTB(1:MAXLEVEL), BESTX(1:MAXLEVEL), BESTY(1:MAXLEVEL) ) FIXED
BINARY (31);
DECLARE ( WCKSFLAG, WCQSFLAG ) BIT(1) ALIGNED;
DECLARE ( A, B, X, Y, RES ) FIXED BINARY (31);


/* initialize board to starting position */
DECLARE BOARD(0:7, 0:7) FIXED BINARY (31) STATIC INITIAL (
-500, -270, -300, -900, -7500, -300, -270, -500,
-100, -100, -100, -100, -100, -100, -100, -100,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
100, 100, 100, 100, 100, 100, 100, 100,
500, 270, 300, 900, 5000, 300, 270, 500 );

LEVEL=0; A=-1; RES=0;
WCKSFLAG = '0'B ; WCQSFLAG = '0'B;
/* main loop: get white move from user, calculate black move */
DO FOREVER;
SCORE=0;
CALL IO(A, B, X, Y, RES);
RES=EVALUATE(-1, 10000);
A=BESTA(1); B=BESTB(1); X=BESTX(1); Y=BESTY(1);
END;

/* figure out if white is in check */
INCHECK: PROCEDURE () RETURNS( FIXED BINARY (31)) OPTIONS (REORDER);
DECLARE (XX(0:26), YY(0:26), CC(0:26)) FIXED BINARY (31);
DECLARE (I, A, B, X, Y, NDX) FIXED BINARY (31);

DO B = 0 TO 7;
DO A = 0 TO 7;
IF BOARD(B, A)>=0 THEN
ITERATE;
CALL MOVELIST(A, B, XX, YY, CC, NDX);
/* iterate through move list and see if */
/* piece can get to king */
DO I = 0 TO NDX BY 1;
X = XX(I);
Y = YY(I);
IF BOARD(Y, X) = 5000 THEN
RETURN (1);
END;
END;
END;
RETURN (0);
END INCHECK;

EVALUATE: PROCEDURE (ID, PRUNE) RETURNS ( FIXED BINARY (31) ) RECURSIVE;
DECLARE ( ID, PRUNE ) FIXED BINARY (31);
/* local variables. */
DECLARE ( XX(0:26), YY(0:26), CC(0:26) ) FIXED BINARY (31);
DECLARE ( A, B, X, Y, C, OLDSCORE, BESTSCORE, MOVER, TARG, NDX,
I ) FIXED BINARY (31);

LEVEL=LEVEL+1;
BESTSCORE=10000*ID;
DO B=7 TO 0 BY -1;
DO A=7 TO 0 BY -1;
/* generate the moves for all the pieces */
/* and iterate through them */
IF SIGN(BOARD(B,A))^=ID THEN
ITERATE;
CALL MOVELIST (A, B, XX, YY, CC, NDX);
DO I=0 TO NDX BY 1;
X=XX(I); Y=YY(I); C=CC(I);
OLDSCORE=SCORE; MOVER=BOARD(B,A); TARG=BOARD(Y,X);
/* make the move and evaluate the new position */
/* recursively. Targ holds the relative value of the piece */
/* allowing use to calculate material gain/loss */
CALL MAKEMOVE (A, B, X, Y, C);
IF LEVEL<MAXLEVEL THEN
DO;
SCORE=SCORE+EVALUATE(-ID,
BESTSCORE-TARG+ID*(8-ABS(4-X)-ABS(4-Y)));
END;
SCORE=SCORE+TARG-ID*(8-ABS(4-X)-ABS(4-Y));
/* we want to minimize the maximum possible loss */
/* for black */
IF (ID<0 & SCORE>BESTSCORE) | (ID>0 & SCORE<BESTSCORE) THEN
DO;
BESTA(LEVEL)=A; BESTB(LEVEL)=B;
BESTX(LEVEL)=X; BESTY(LEVEL)=Y;
BESTSCORE=SCORE;
IF (ID<0 & BESTSCORE>=PRUNE) | (ID>0 & BESTSCORE<=PRUNE) THEN
DO;
BOARD(B,A)=MOVER; BOARD(Y,X)=TARG; SCORE=OLDSCORE;
LEVEL=LEVEL-1;
RETURN (BESTSCORE);
END;
END;
BOARD(B,A)=MOVER; BOARD(Y,X)=TARG; SCORE=OLDSCORE;
END;
END;
END;
LEVEL=LEVEL-1;
RETURN (BESTSCORE);
END EVALUATE;

/* make a move given the start square and end square */
/* currently always promotes to queen */
/* Moves from position (A, B) to position (X,Y). */

MAKEMOVE: PROCEDURE (A, B, X, Y, C) OPTIONS (REORDER);
DECLARE (A, B, X, Y, C) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26)) FIXED BINARY (31);

BOARD(Y, X)=BOARD(B, A); BOARD(B, A)=0;
IF Y = 0 & BOARD(Y, X) = 100 THEN
BOARD(Y, X)= C;
IF Y = 7 & BOARD(Y, X) = -100 THEN
BOARD(Y, X)= C;
RETURN;
END MAKEMOVE;

/* select appropriate subprogram to populate xx and yy arrays */
/* with piece moves */
/* xx = x coordinates */
/* yy = y coordinates */
/* cc = pawn promotion if applicable */
/* ndx = index into xx, yy, cc arrays showing the number of */
/* elements that the arrays have been populated with */
MOVELIST: PROCEDURE (A, B, XX, YY, CC, NDX) OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26), CC(0:26)) FIXED BINARY (31);
DECLARE (NDX) FIXED BINARY (31);
DECLARE (PIECE) FIXED BINARY (31);

PIECE=ABS(BOARD(B, A)); NDX=-1;
SELECT (PIECE);
WHEN (100) CALL PAWN(A, B, XX, YY, CC, NDX);
WHEN (270) CALL KNIGHT(A, B, XX, YY, NDX);
WHEN (300) CALL BISHOP(A, B, XX, YY, NDX);
WHEN (500) CALL ROOK(A, B, XX, YY, NDX);
WHEN (900) CALL QUEEN(A, B, XX, YY, NDX);
OTHERWISE CALL KING(A, B, XX, YY, NDX);
END;
RETURN;
END MOVELIST;

/* queen is a combination of rook and bishop */
QUEEN: PROCEDURE (A, B, XX, YY, NDX) OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26)) FIXED BINARY (31);
DECLARE NDX FIXED BINARY (31);

CALL ROOK(A, B, XX, YY, NDX);
CALL BISHOP(A, B, XX, YY, NDX);
RETURN;
END QUEEN;


KING: PROCEDURE (A, B, XX, YY, NDX) OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26)) FIXED BINARY (31);
DECLARE NDX FIXED BINARY (31);
DECLARE (ID, DX, DY) FIXED BINARY (31);

ID=SIGN(BOARD(B, A));
/* negative = left or up */
/* positive = right or down */
/* zero = no change */
DO DY=-1 TO 1;
IF B+DY<0 | B+DY>7 THEN
ITERATE;
DO DX=-1 TO 1;
IF A+DX<0 | A+DX>7 THEN
ITERATE;
IF ID^=SIGN(BOARD(B+DY,A+DX)) THEN
DO;
NDX=NDX+1; XX(NDX)=A+DX; YY(NDX)=B+DY;
END;
END;
END;
RETURN;
END KING;


PAWN: PROCEDURE (A, B, XX, YY, CC, NDX) OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26), CC(0:26)) FIXED BINARY (31);
DECLARE NDX FIXED BINARY (31);
DECLARE (I, ID) FIXED BINARY (31);

ID = SIGN(BOARD(B, A));
IF ((A - 1) >= 0) & ((A - 1) <= 7) & ((B - ID) >= 0) & ((B -
ID) <= 7) THEN
DO;
IF SIGN(BOARD((B - ID), (A - 1))) = -ID THEN
DO;
IF ((ID<0) & (B = 6)) | ((ID>0) & (B = 1)) THEN
DO;
CC(NDX+1) = 270*ID;
CC(NDX+2) = 300*ID;
CC(NDX+3) = 500*ID;
CC(NDX+4) = 900*ID;
DO I=1 TO 4;
NDX = NDX + 1;
XX(NDX) = A - 1;
YY(NDX) = B - ID;
END;
END;
ELSE
DO;
NDX = NDX + 1;
XX(NDX) = A - 1;
YY(NDX) = B - ID;
END;
END;
END;
IF ((A + 1) >= 0) & ((A + 1) <= 7) & ((B - ID) >= 0) & ((B
- ID) <= 7) THEN
DO;
IF SIGN(BOARD((B - ID), (A + 1))) = -ID THEN
DO;
IF ((ID<0) & (B = 6)) | ((ID>0) & (B = 1)) THEN
DO;
CC(NDX+1) = 270*ID;
CC(NDX+2) = 300*ID;
CC(NDX+3) = 500*ID;
CC(NDX+4) = 900*ID;
DO I=1 TO 4;
NDX = NDX + 1;
XX(NDX) = A + 1;
YY(NDX) = B - ID;
END;
END;
ELSE
DO;
NDX = NDX + 1;
XX(NDX) = A + 1;
YY(NDX) = B - ID;
END;
END;
END;
IF (A >= 0) & (A <= 7) & ((B - ID) >= 0) & ((B - ID) <= 7) THEN
DO;
IF BOARD((B - ID), A) = 0 THEN
DO;
IF ((ID<0) & (B = 6)) | ((ID>0) & (B = 1)) THEN
DO;
CC(NDX+1) = 270*ID;
CC(NDX+2) = 300*ID;
CC(NDX+3) = 500*ID;
CC(NDX+4) = 900*ID;
DO I=1 TO 4;
NDX = NDX + 1;
XX(NDX) = A;
YY(NDX) = B - ID;
END;
END;
ELSE
DO;
NDX = NDX + 1;
XX(NDX) = A;
YY(NDX) = B - ID;
END;
IF ((ID < 0) & (B = 1)) | ((ID > 0) & (B = 6)) THEN
DO;
IF BOARD((B - ID - ID), A) = 0 THEN
DO;
NDX = NDX + 1;
XX(NDX) = A;
YY(NDX) = B - ID - ID;
END;
END;
END;
END;
END PAWN;


BISHOP: PROCEDURE (A, B, XX, YY, NDX) OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26)) FIXED BINARY (31);
DECLARE NDX FIXED BINARY (31);
DECLARE (ID, DXY, X, Y) FIXED BINARY;

ID=SIGN(BOARD(B, A));
/* four diagonal directions */
DO DXY=1 TO 7;
X=A-DXY; IF (X<0) THEN LEAVE;
Y=B+DXY; IF (Y>7) THEN LEAVE;
IF ID^=SIGN(BOARD(Y, X)) THEN /* cannot capture piece of same color */
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
IF BOARD(Y, X)^=0 THEN
LEAVE /* cannot jump over pieces */;
END;
DO DXY=1 TO 7;
X=A+DXY; IF (X>7) THEN LEAVE;
Y=B+DXY; IF (Y>7) THEN LEAVE;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
IF BOARD(Y, X)^=0 THEN
LEAVE;
END;
DO DXY=1 TO 7;
X=A-DXY; IF (X<0) THEN LEAVE;
Y=B-DXY; IF (Y<0) THEN LEAVE;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
IF BOARD(Y, X)^=0 THEN
LEAVE;
END;
DO DXY=1 TO 7;
X=A+DXY; IF (X>7) THEN LEAVE;
Y=B-DXY; IF (Y<0) THEN LEAVE;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
IF BOARD(Y, X)^=0 THEN
LEAVE;
END;
END BISHOP;

ROOK: PROCEDURE (A, B, XX, YY, NDX) OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26)) FIXED BINARY (31);
DECLARE NDX FIXED BINARY (31);
DECLARE (ID, X, Y) FIXED BINARY (31);

ID=SIGN(BOARD(B, A));
/* four different orthagonal directions */
DO X = A-1 TO 0 BY -1;
IF ID^=SIGN(BOARD(B, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=B;
END;
IF BOARD(B, X)^=0 THEN
LEAVE;
END;
DO X = A+1 TO 7 BY 1;
IF ID^=SIGN(BOARD(B, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=B;
END;
IF BOARD(B, X)^=0 THEN
LEAVE;
END;
DO Y = B-1 TO 0 BY -1;
IF ID^=SIGN(BOARD(Y, A)) THEN
DO;
NDX=NDX+1; XX(NDX)=A; YY(NDX)=Y;
END;
IF BOARD(Y, A)^=0 THEN
LEAVE;
END;
DO Y = B+1 TO 7 BY 1;
IF ID^=SIGN(BOARD(Y, A)) THEN
DO;
NDX=NDX+1; XX(NDX)=A; YY(NDX)=Y;
END;
IF BOARD(Y, A)^=0 THEN
LEAVE;
END;
RETURN;
END ROOK;


KNIGHT: PROCEDURE (A, B, XX, YY, NDX) OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);
DECLARE (XX(0:26), YY(0:26)) FIXED BINARY (31);
DECLARE NDX FIXED BINARY (31);
DECLARE (ID, X, Y) FIXED BINARY (31);

ID=SIGN(BOARD(B, A));
/* 2 vertical, 1 horizontal */
/* or 2 horizontal, 1 vertical */
X=A-1; Y=B-2;
IF X>=0 & Y>=0 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
X=A-2; Y=B-1;
IF X>=0 & Y>=0 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
X=A+1; Y=B-2;
IF X<=7 & Y>=0 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
X=A+2; Y=B-1;
IF X<=7 & Y>=0 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
X=A-1; Y=B+2;
IF X>=0 & Y<=7 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
X=A-2; Y=B+1;
IF X>=0 & Y<=7 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
X=A+1; Y=B+2;
IF X<=7 & Y<=7 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
X=A+2; Y=B+1;
IF X<=7 & Y<=7 THEN
DO;
IF ID^=SIGN(BOARD(Y, X)) THEN
DO;
NDX=NDX+1; XX(NDX)=X; YY(NDX)=Y;
END;
END;
RETURN;
END KNIGHT;

/* display chessboard */
SHOW: PROCEDURE OPTIONS (REORDER);
DECLARE (A, B) FIXED BINARY (31);

DO B=0 TO 7;
PUT SKIP EDIT ( ' +---+---+---+---+---+---+---+---+' )(COL(20), A);
PUT SKIP EDIT ( 8-B, ' |' )(COL(20), F(1), A);
DO A=0 TO 7;
SELECT (BOARD(B, A));
WHEN (-7500) PUT EDIT ( ' *k|' )(A);
WHEN (-900) PUT EDIT ( ' *q|' )(A);
WHEN (-500) PUT EDIT ( ' *r|' )(A);
WHEN (-300) PUT EDIT ( ' *b|' )(A);
WHEN (-270) PUT EDIT ( ' *n|' )(A);
WHEN (-100) PUT EDIT ( ' *p|' )(A);
WHEN (0) PUT EDIT ( ' |' )(A);
WHEN (100) PUT EDIT ( ' P |' )(A);
WHEN (270) PUT EDIT ( ' N |' )(A);
WHEN (300) PUT EDIT ( ' B |' )(A);
WHEN (500) PUT EDIT ( ' R |' )(A);
WHEN (900) PUT EDIT ( ' Q |' )(A);
WHEN (5000) PUT EDIT ( ' K |' )(A);
END;
END;
END;
PUT SKIP EDIT ( ' +---+---+---+---+---+---+---+---+' )(COL(20), A);
PUT SKIP EDIT ( ' A B C D E F G H' )(COL(20), A);
RETURN;
END SHOW;

/* io -- input/output: */
/* display black move and get white move */
IO: PROCEDURE (A, B, X, Y, RES) OPTIONS (REORDER);
DECLARE (A, B, X, Y, RES) FIXED BINARY (31);
DECLARE ( INPUT ) CHARACTER (10);
DECLARE (XX(0:26), YY(0:26), CC(0:26)) FIXED BINARY (31);
DECLARE (I, K, NDX, PIECE, TARG, MOVER, C) FIXED BINARY (31);
DECLARE NULL FIXED BINARY; /* This variable is assigned but never used. */
DECLARE LETTER (0:7) CHAR (1) STATIC INITIAL
('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H');

DECLARE SL FIXED BINARY;

/* >>>>>>>>> CAUTION - WATCH FOR UNINITIALIZED XX, YY <<<<<<<<<<< */
DECLARE ( WCKSOLD, WCQSOLD ) BIT(1) ALIGNED;

ON ERROR SNAP BEGIN;
PUT SKIP LIST ('at line ' || TRIM(SL) );
END;

SL = SOURCELINE();

IF A>=0 THEN
DO;
IF RES<-2500 THEN
DO;
PUT SKIP LIST ( 'I RESIGN');
CALL SHOW;
PUT SKIP;
STOP;
END;
PIECE=BOARD(Y, X);
CALL MAKEMOVE(A, B, X, Y, C);
PUT SKIP EDIT ( 'MY MOVE: ' )(A);
PUT EDIT ( LETTER(A), 8-B, '-', LETTER(X), 8-Y)
(A, F(1), A, A, F(1));

SELECT (PIECE);
WHEN (100) PUT SKIP LIST ( 'I TOOK YOUR PAWN');
WHEN (270) PUT SKIP LIST ( 'I TOOK YOUR KNIGHT');
WHEN (300) PUT SKIP LIST ( 'I TOOK YOUR BISHOP');
WHEN (500) PUT SKIP LIST ( 'I TOOK YOUR ROOK');
WHEN (900) PUT SKIP LIST ( 'I TOOK YOUR QUEEN');
WHEN (5000) PUT SKIP LIST ( 'I TOOK YOUR KING');
OTHERWISE ;
END;
END;
DO_FOREVER1:
DO FOREVER;
CALL SHOW;
PUT SKIP EDIT ( 'YOUR MOVE: ' )(A);
RETRY_MOVE:
GET EDIT (INPUT) (L);
CALL UPCASE(INPUT);
IF (INPUT = 'QUIT') | (INPUT = 'BYE') | (INPUT = 'EXIT') THEN
STOP;
/* castling */
IF (INPUT = 'O-O') | (INPUT = '0-0') THEN
DO;
IF INCHECK() ^= 0 THEN
ITERATE DO_FOREVER1; /* cannot castle out of check */
IF WCKSFLAG THEN
ITERATE DO_FOREVER1;
IF BOARD(7, 7) ^= 500 THEN
ITERATE DO_FOREVER1;
IF (BOARD (7,6) ^= 0) | (BOARD(7,5) ^=0) THEN
ITERATE DO_FOREVER1;
BOARD(7, 4) = 0;
BOARD(7, 5) = 5000;
IF INCHECK() ^= 0 THEN /* cannot castle through check */
DO;
BOARD(7, 4) = 5000;
BOARD(7, 5) = 0;
ITERATE DO_FOREVER1;
END;
ELSE
DO;
BOARD(7, 4) = 5000;
BOARD(7, 5) = 0;
END;
BOARD(7, 6) = 5000;
BOARD(7, 4) = 0;
BOARD(7, 5) = 500;
BOARD(7, 7) = 0;
IF INCHECK() ^= 0 THEN /* cannot castle into check */
DO;
BOARD(7, 6) = 0;
BOARD(7, 4) = 5000;
BOARD(7, 5) = 0;
BOARD(7, 7) = 500;
ITERATE DO_FOREVER1;
END;
ELSE
DO;
WCKSFLAG = '1'B;
WCQSFLAG = '1'B;
RETURN;
END;
END;
IF (INPUT = 'O-O-O') | (INPUT = '0-0-0') THEN
DO;
IF INCHECK() ^= 0 THEN
ITERATE DO_FOREVER1; /* cannot castle out of check */
IF WCQSFLAG THEN
ITERATE DO_FOREVER1;
IF BOARD(7,0) ^= 500 THEN
ITERATE DO_FOREVER1;
IF (BOARD(7,1) ^= 0) | (BOARD(7,2) ^= 0) | (BOARD(7,3) ^= 0) THEN
ITERATE DO_FOREVER1;
BOARD(7, 4) = 0;
BOARD(7, 3) = 5000;
IF INCHECK() ^= 0 THEN /* cannot castle through check */
DO;
BOARD(7, 4) = 5000;
BOARD(7, 3) = 0;
ITERATE DO_FOREVER1;
END;
ELSE
DO;
BOARD(7, 4) = 5000;
BOARD(7, 3) = 0;
END;
BOARD(7, 2) = 5000;
BOARD(7, 4) = 0;
BOARD(7, 3) = 500;
BOARD(7, 0) = 0;
IF INCHECK() ^= 0 THEN /* cannot castle into check */
DO;
BOARD(7, 2) = 0;
BOARD(7, 4) = 5000;
BOARD(7, 3) = 0;
BOARD(7, 0) = 500;
ITERATE DO_FOREVER1;
END;
ELSE
DO;
WCKSFLAG = '1'B;
WCQSFLAG = '1'B;
RETURN;
END;
END;

/* Check that only the proper letters A-H etc are used. */
/* (this does not check that the letters are in their correct columns.) */
I = VERIFY (TRIM(INPUT), 'ABCDEFGHO0-12345678');
IF I > 0 THEN
DO;
PUT SKIP LIST ('That move was invalid. Please try again:');
GO TO RETRY_MOVE;
END;

SL = SOURCELINE();

/* (A,B) are co-ordinates of the from position. */
/* (X,Y) are co-ordinates of the destination position. */

/* Translate algebraic notation to co-ordinates. */

B = 8 - INDEX ('12345678', SUBSTR(INPUT, 2, 1) );
A = INDEX ('ABCDEFGH', SUBSTR(INPUT, 1, 1) ) - 1;
X = INDEX ('ABCDEFGH', SUBSTR(INPUT, 4, 1) ) - 1;
Y = 8 - INDEX ('12345678', SUBSTR(INPUT, 5, 1) );

PUT SKIP DATA (A, B);
PUT SKIP DATA (X, Y);
STOP;
IF B>7 | B<0 | A>7 | A<0 | X>7 | X<0 | Y>7 | Y<0 THEN
DO;
PUT SKIP LIST ('Illegal move. Please try again');
ITERATE DO_FOREVER1;
END;
IF BOARD(B,A)<=0 THEN
ITERATE DO_FOREVER1;
/* en passant capture */
IF (Y = 2) & (B = 3) & ((X = A-1) | (X = A+1)) THEN
DO;
IF (BOARD(B,A) = 100) & (BOARD(Y,X) = 0) & (BOARD(Y+1,X) =-100) THEN
DO;
IF (BESTB(1) = 1) & (BESTA(1) = X) THEN
DO;
MOVER = BOARD(B,A);
TARG = BOARD(Y,X);
CALL MAKEMOVE(A,B,X,Y,C);
BOARD(Y+1,X)=0;
IF (INCHECK()) = 0 THEN
RETURN;
BOARD(B,A) = MOVER;
BOARD(Y, X) = TARG;
BOARD(Y+1,X) = -100;
ITERATE DO_FOREVER1;
END;
END;
END;
/* check if selected white move is on list of moves */
CALL MOVELIST(A, B, XX, YY, CC, NDX);
DOK_LOOP:
DO K = 0 TO NDX BY 1;
IF (X = XX(K)) & (Y = YY(K)) THEN
DO;
MOVER = BOARD(B, A);
TARG = BOARD(Y, X);
IF Y = 0 THEN
FOREVER_LOOP:
DO FOREVER;
PUT SKIP EDIT ( 'PROMOTION PIECE: ' )(A);
GET EDIT (INPUT) (L);
CALL UPCASE(INPUT);
SELECT (INPUT);
WHEN ('N', 'KT', 'KNIGHT', 'HORSE') C = 270;
WHEN ('B', 'BISHOP') C = 300;
WHEN ('R', 'ROOK') C = 500;
WHEN ('Q', 'QUEEN') C = 900;
OTHERWISE ITERATE;
END;
LEAVE FOREVER_LOOP;
END;
CALL MAKEMOVE(A, B, X, Y, C);
IF MOVER = 5000 THEN
DO;
WCQSOLD = WCQSFLAG;
WCKSOLD = WCKSFLAG;
WCKSFLAG = '1'B;
WCQSFLAG = '1'B;
END;
IF (A = 0) & (B = 7) & (MOVER = 500) THEN
DO;
WCQSOLD = WCQSFLAG;
WCQSFLAG = '1'B;
END;
IF (A = 7) & (B = 7) & (MOVER = 500) THEN
DO;
WCKSOLD = WCKSFLAG;
WCKSFLAG = '1'B;
END;
IF INCHECK() = 0 THEN
RETURN;
BOARD(B, A) = MOVER;
BOARD(Y, X) = TARG;
IF MOVER = 5000 THEN
DO;
WCQSFLAG = WCQSOLD;
WCKSFLAG = WCKSOLD;
END;
IF (A = 0) & (B = 7) & (MOVER = 500) THEN
WCQSFLAG = WCQSOLD;
IF (A = 7) & (B = 7) & (MOVER = 500) THEN
WCKSFLAG = WCKSOLD;
LEAVE DOK_LOOP;
END;
END;
END;
END IO;

/* convert string to uppercase */
UPCASE: PROCEDURE (STRING) OPTIONS (REORDER);
DECLARE ( STRING ) CHARACTER (*);

STRING = TRANSLATE (STRING, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz' );

END UPCASE;

END CHESS;

+ 13
- 0
it/it-projects/plugins/project/src/pli/hasissues.pli View File

@@ -0,0 +1,13 @@
foo: proc options(main);
declare i fixed decimal init (0);

if i = 42 then
put list ('The answer is... '); /* Non-Compliant - This statement should be enclosed in a DO ... END one */
put list ('42!'); /* This statement will always and unconditionally be executed! Its indentation level is misleading. */
end;

bar: proc options(main);
/* Non-Compliant - The trailing space, following "Hello," is not readable and could be removed by some text editors */
put list ('Hello,
world');
end;

+ 67
- 0
it/it-projects/plugins/project/src/pli/maxlen.pli View File

@@ -0,0 +1,67 @@
/* Copyright (c) 1995 by R. A. Vowels, from "Introduction to PL/I, Algorithms, and */
/* Structured Programming". Permission is given to reproduce and to use these procedures */
/* as part of a program, and to include them as part of a larger work to be sold for profit. */
/* However, the user is not permitted to sell the procedures separately. Provided always */
/* that these procedures and this copyright notice are reproduced in full. */

DECLARE MAXLENGTH GENERIC
(MAXLEN_graphic WHEN (GRAPHIC),
MAXLEN_bit WHEN (BIT),
MAXLEN_char WHEN (*) );

/* This procedure is provided for those who must have the */
/* built-in function MAXLENGTH. Do not call it often, as */
/* run-time is relatively high. */
/* This procedure returns the maximum length that a VARYING character string may take. */
MAXLEN_char:
PROCEDURE (STRING) RETURNS (FIXED BINARY);
DECLARE STRING CHARACTER (*) VARYING;

DECLARE LENGTH BUILTIN;
DECLARE TEMP CHARACTER (32767) VARYING;
DECLARE STR CHARACTER (32767) STATIC INITIAL ( ' ' );
DECLARE K FIXED BINARY;

TEMP = STRING; /* Preserve a copy of the string. */
(NOSTRINGSIZE):
STRING = STR; /* Assign something very long to it. */
K = LENGTH (STRING); /* Find out how long the variable is. */
STRING = TEMP; /* Restore the string. */
RETURN (K); /* The declared length of the string. */
END MAXLEN_char;

/* This procedure returns the maximum length that a VARYING graphic string may take. */
MAXLEN_graphic:
PROCEDURE (STRING) RETURNS (FIXED BINARY);
DECLARE STRING GRAPHIC (*) VARYING;

DECLARE LENGTH BUILTIN;
DECLARE TEMP GRAPHIC (16383) VARYING;
DECLARE STR GRAPHIC (16383) STATIC INITIAL ( ' ' );
DECLARE K FIXED BINARY;

TEMP = STRING; /* Preserve a copy of the string. */
(NOSTRINGSIZE):
STRING = STR; /* Assign something very long to it. */
K = LENGTH (STRING); /* Find out how long the variable is. */
STRING = TEMP; /* Restore the string. */
RETURN (K); /* The declared length of the string. */
END MAXLEN_graphic;

/* This procedure returns the maximum length that a VARYING bit string may take. */
MAXLEN_bit:
PROCEDURE (STRING) RETURNS (FIXED BINARY);
DECLARE STRING BIT (*) VARYING;

DECLARE LENGTH BUILTIN;
DECLARE TEMP BIT (32767) VARYING;
DECLARE STR BIT (32767) STATIC INITIAL ( '0'B);
DECLARE K FIXED BINARY;

TEMP = STRING; /* Preserve a copy of the string. */
(NOSTRINGSIZE):
STRING = STR; /* Assign something very long to it. */
K = LENGTH (STRING); /* Find out how long the variable is. */
STRING = TEMP; /* Restore the string. */
RETURN (K); /* The declared length of the string. */
END MAXLEN_bit;

+ 246
- 0
it/it-projects/plugins/project/src/pli/search.pli View File

@@ -0,0 +1,246 @@
/* Copyright (c) 1995 by R. A. Vowels, from "Introduction to PL/I, Algorithms, and */
/* Structured Programming". Permission is given to reproduce and to use these procedures */
/* as part of a program, and to include them as part of a larger work to be sold for profit. */
/* However, the user is not permitted to sell the procedures separately. Provided always */
/* that these procedures and this copyright notice are reproduced in full. */

DECLARE SEARCH GENERIC
(SEARCH_all_graphic WHEN ( GRAPHIC, GRAPHIC),
SEARCH_all_graphic WHEN ( GRAPHIC, *),
SEARCH_all_graphic WHEN (*, GRAPHIC),
SEARCH_all_bit WHEN ( BIT, BIT),
SEARCH_all WHEN (*,*),
SEARCH_sub_graphic WHEN ( GRAPHIC, GRAPHIC, *),
SEARCH_sub_graphic WHEN ( GRAPHIC, *, *),
SEARCH_sub_graphic WHEN (*, GRAPHIC, *),
SEARCH_sub_bit WHEN ( BIT, BIT, *),
SEARCH_sub WHEN (*,*,*) );

/* This function procedure searches the first string STRING for any characters given in the */
/* second string SUB. If there are any such characters, the function returns the position */
/* of the left-most. */
SEARCH_all:
PROCEDURE (STRING, SUB) OPTIONS (REORDER)
RETURNS (FIXED BINARY (31));
/* INCOMING: STRING = the string to be searched; */
/* SUB = contains characters to look for. */
DECLARE (STRING, SUB) CHARACTER (*);

DECLARE (LENGTH, SUBSTR,
UNSPEC, INDEX) BUILTIN;
DECLARE Table (0:255) BIT (1) STATIC ALIGNED;
DECLARE (J, K) FIXED BINARY (31);

IF LENGTH (SUB) = 0 THEN /* Nothing with which to search. */
RETURN (0);
IF LENGTH (STRING) = 0 THEN /* There's nothing to search. */
RETURN (0);
IF LENGTH (SUB) = 1 THEN /* Looking for one character is fast. */
RETURN (INDEX (STRING, SUB));

/* SETS UP A LOOK-UP TABLE (which is independent of the character set). */
Table = '0'B; /* All entries are FALSE. */
DO J = 1 TO LENGTH (Sub);
K = UNSPEC (SUBSTR (Sub, J, 1));
Table (K) = '1'B; /* Table(k) is TRUE for each character in SUB. */
END;

/* CONDUCT THE SEARCH. */
DO J = 1 TO LENGTH (STRING);
K = UNSPEC (SUBSTR (STRING, J, 1));
IF Table(K) THEN /* TRUE when a SUB character matches one in */
RETURN (J); /* STRING. */
END;
RETURN (0); /* Unsuccessful search. */
END SEARCH_all;

/* This function procedure searches the first string STRING for any characters given in the */
/* second string SUB. If there are any such characters, the function returns the position */
/* of the left-most. */
/* The search is performed from left to right, commencing from character position */
/* POSITION. */
SEARCH_sub:
PROCEDURE (STRING, SUB, POSITION) RETURNS (FIXED BINARY (31));
/* INCOMING: STRING = the string to be searched; */
/* SUB = contains characters to look for; */
/* POSITION = where to start the search (measured from the left-hand end of */
/* STRING). */
DECLARE (STRING, SUB) CHARACTER (*);
DECLARE POSITION FIXED BINARY (31);

DECLARE (LENGTH, INDEX) BUILTIN;
DECLARE K FIXED BINARY (31);

IF (Position > LENGTH (String)+1) | (Position <= 0) THEN
DO;
SIGNAL STRINGRANGE;
RETURN (0);
END;
IF LENGTH (STRING) = 0 THEN RETURN (0);
K = SEARCH_all ( SUBSTR (STRING, POSITION), SUB);
IF K = 0 THEN RETURN (0);
RETURN (POSITION+K-1);
END SEARCH_sub;

/* This function procedure searches the first string STRING for any characters given in the */
/* second string SUB. If there are any such characters, the function returns the position */
/* of the left-most. */
SEARCH_all_graphic:
PROCEDURE (STRING, SUB) OPTIONS (REORDER)
RETURNS ( FIXED BINARY (31));
/* INCOMING: STRING = the string to be searched; */
/* SUB = contains characters to look for. */
DECLARE (STRING, SUB) GRAPHIC (*);

DECLARE (LENGTH,
SUBSTR,
INDEX) BUILTIN;
DECLARE (J, K) FIXED BINARY (31);
DECLARE Ch GRAPHIC (1);

IF LENGTH (SUB) = 0 THEN /* Nothing with which to search. */
RETURN (0);
IF LENGTH (STRING) = 0 THEN /* There's nothing to search. */
RETURN (0);
IF LENGTH (SUB) = 1 THEN /* Looking for one character is fast. */
RETURN (INDEX (STRING, SUB));

DO J = 1 TO LENGTH(String);
Ch = SUBSTR(String, J, 1); /* Select one graphic character from the string to*/
/* be searched. */
K = INDEX (Sub, Ch); /* Check whether it is one of those on our search list.*/
IF K ^= 0 THEN /* If it is, we are done. */
RETURN (J);
END;

RETURN (0); /* The search was unsuccessful. */
END SEARCH_all_graphic;

/* This function procedure searches the first string STRING for any graphic characters */
/* given in the second string SUB. If there are any such graphic characters, the function */
/* returns the position of the left-most. */
/* The search is performed from left to right, commencing from graphic character position */
/* POSITION. */
SEARCH_sub_graphic:
PROCEDURE (STRING, SUB, POSITION) RETURNS (FIXED BINARY (31));
/* INCOMING: STRING = the string to be searched; */
/* SUB = contains characters to look for; */
/* POSITION = where to start the search (measured from the left-hand end of */
/* STRING). */
DECLARE (STRING, SUB) GRAPHIC (*);
DECLARE POSITION FIXED BINARY (31);

DECLARE (LENGTH, SUBSTR,
INDEX) BUILTIN;
DECLARE (J, K) FIXED BINARY (31);
DECLARE Ch GRAPHIC (1);

IF (Position > LENGTH (String)+1) | (Position <= 0) THEN
DO;
SIGNAL STRINGRANGE;
RETURN (0);
END;
IF LENGTH (SUB) = 0 THEN /* Nothing with which to search. */
RETURN (0);
IF LENGTH (STRING) = 0 THEN /* There's nothing to search. */
RETURN (0);
IF LENGTH (SUB) = 1 THEN /* Looking for one character is fast. */
RETURN (INDEX (SUBSTR (STRING, Position), SUB)+Position-1);

DO J = Position TO LENGTH(String);
Ch = SUBSTR(String, J, 1); /* Select one graphic character from the string to */
/* be searched. */
K = INDEX (Sub, Ch); /* Check whether it is one of those on our search list.*/
IF K ^= 0 THEN /* If it is, we are done. */
RETURN (J);
END;

RETURN (0); /* The search was unsuccessful. */

END SEARCH_sub_graphic;

/* This function procedure searches the first string STRING for any bits given in the */
/* second string SUB. If there are any such bits, the function returns the position */
/* of the left-most. */
SEARCH_all_bit:
PROCEDURE (STRING, SUB) OPTIONS (REORDER)
RETURNS ( FIXED BINARY (31));
/* INCOMING: STRING = the string to be searched; */
/* SUB = contains bits to look for. */
DECLARE (STRING, SUB) BIT (*);

DECLARE (LENGTH, SUBSTR,
INDEX) BUILTIN;
DECLARE (J, K) FIXED BINARY (31);

IF LENGTH (SUB) = 0 THEN /* Nothing with which to search. */
RETURN (0);
IF LENGTH (STRING) = 0 THEN /* There's nothing to search. */
RETURN (0);
IF LENGTH (SUB) = 1 THEN /* Looking for one bit is fast. */
RETURN (INDEX (STRING, SUB));

/* When we come here, SUB has 2 or more bits. */

K = INDEX (SUB, ^SUBSTR(SUB, 1, 1)); /* Look for a bit of the opposite kind. */

IF K > 0 THEN /* No need for a search -- the key SUB consists */
/* of both 0 and 1. */
RETURN (1); /* Always get a match at position 1. */

/* The pattern SUB contains either all ones or all zeros. */

/* CONDUCT THE SEARCH. */
IF SUBSTR(SUB, 1, 1) THEN
RETURN (INDEX(STRING, '1'B));
ELSE
RETURN (INDEX(STRING, '0'B));

END SEARCH_all_bit;

/* This function procedure searches the first string STRING for any bits given in the */
/* second string SUB. If there are any such bits, the function returns the position */
/* of the left-most. */
SEARCH_sub_bit:
PROCEDURE (String, Sub, Position) OPTIONS (REORDER)
RETURNS ( FIXED BINARY (31));
/* INCOMING: STRING = the string to be searched; */
/* SUB = contains bits to look for. */
DECLARE (String, Sub) BIT (*);

DECLARE (LENGTH, SUBSTR,
INDEX) BUILTIN;
DECLARE (J, K) FIXED BINARY (31);

IF (Position > LENGTH (String)+1) | (Position <= 0) THEN
DO;
SIGNAL STRINGRANGE;
RETURN (0);
END;
IF LENGTH (SUB) = 0 THEN /* Nothing with which to search. */
RETURN (0);
IF LENGTH (STRING) = 0 THEN /* There's nothing to search. */
RETURN (0);
IF Position = LENGTH(String)+1 THEN
RETURN (0);
IF LENGTH (SUB) = 1 THEN /* Looking for one bit is fast. */
RETURN (INDEX(SUBSTR(STRING, Position), SUB)+Position-1);

/* When we come here, SUB has 2 or more bits. */

K = INDEX (SUBSTR(String, Position), ^SUBSTR(SUB, 1, 1));
/* Look for a bit of the opposite kind. */

IF K > 0 THEN /* No need for a search -- the key SUB consists */
/* of both 0 and 1. */
RETURN (Position); /* Always get a match at position "Position". */

/* The pattern SUB contains either all ones or all zeros. */

/* CONDUCT THE SEARCH. */
IF SUBSTR(SUB, 1, 1) THEN
RETURN (INDEX(SUBSTR(STRING, Position), '1'B)+Position-1);
ELSE
RETURN (INDEX(SUBSTR(STRING, Position), '0'B)+Position-1);

END SEARCH_sub_bit;

+ 9
- 0
it/it-projects/plugins/project/src/plsql/ddl.sql View File

@@ -0,0 +1,9 @@
CREATE TABLE OWNER.TABLE01 (ID NUMBER(12));
/
ALTER TABLE OWNER.TABLE01 ADD (COL1 VARCHAR2(4000));
/

CREATE TABLE OWNER.TABLE02 (ID NUMBER(12));
/
ALTER TABLE OWNER.TABLE02 ADD (COL1 VARCHAR2(4000));
/

+ 213
- 0
it/it-projects/plugins/project/src/plsql/ut_report.pkb View File

@@ -0,0 +1,213 @@
/* Formatted on 2002/03/31 23:53 (Formatter Plus v4.5.2) */
CREATE OR REPLACE PACKAGE BODY Utreport
IS
/************************************************************************
GNU General Public License for utPLSQL

Copyright (C) 2000-2003
Steven Feuerstein and the utPLSQL Project
(steven@stevenfeuerstein.com)

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program (see license.txt); if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
************************************************************************
$Log: ut_report.pkb,v $
Revision 1.3 2005/05/11 21:33:36 chrisrimmer
Added testing of reporter infrastructure

Revision 1.2 2004/11/16 09:46:49 chrisrimmer
Changed to new version detection system.

Revision 1.1 2004/07/14 17:01:57 chrisrimmer
Added first version of pluggable reporter packages


************************************************************************/

DEFAULT_REPORTER VARCHAR2(100) := 'Output';
DYNAMIC_PLSQL_FAILURE NUMBER(10) := -6550;

--This is the reporter we have been asked to use
g_reporter VARCHAR2(100);
--This is the reporter we are actually using
--(this differs from the above in the event of error)
g_actual VARCHAR2(100);

FUNCTION parse_it(proc IN VARCHAR2, params IN NUMBER, force_reporter IN VARCHAR2)
RETURN INTEGER
IS
dyn_handle INTEGER := NULL;
query VARCHAR2(1000);
BEGIN
dyn_handle := DBMS_SQL.OPEN_CURSOR;
QUERY := 'BEGIN ut' || NVL(force_reporter, g_actual) || 'Reporter.' || proc ;
IF params = 1 THEN
QUERY := QUERY || '(:p)';
END IF;
QUERY := QUERY || '; END;';
DBMS_SQL.PARSE(dyn_handle, QUERY, DBMS_SQL.NATIVE);
RETURN dyn_handle;
EXCEPTION
WHEN OTHERS THEN
DBMS_SQL.CLOSE_CURSOR (dyn_handle);
RAISE;
END;

PROCEDURE execute_it(dyn_handle IN OUT INTEGER)
IS
dyn_result INTEGER;
BEGIN
dyn_result := DBMS_SQL.EXECUTE (dyn_handle);
DBMS_SQL.CLOSE_CURSOR (dyn_handle);
END;
--We use this to make dynamic calls to reporter packages
PROCEDURE call(proc IN VARCHAR2,
param IN VARCHAR2,
params IN NUMBER := 1,
force_reporter IN VARCHAR2 := NULL,
failover IN BOOLEAN := TRUE)
IS
dyn_handle INTEGER := NULL;
BEGIN
dyn_handle := parse_it(proc, params, force_reporter);
IF params = 1 THEN
DBMS_SQL.BIND_VARIABLE (dyn_handle, 'p', param);
END IF;
execute_it(dyn_handle);
EXCEPTION
WHEN OTHERS THEN
IF dyn_handle IS NOT NULL THEN
DBMS_SQL.CLOSE_CURSOR (dyn_handle);
END IF;
IF g_actual <> DEFAULT_REPORTER THEN
IF NOT failover OR SQLCODE <> DYNAMIC_PLSQL_FAILURE THEN
g_actual := DEFAULT_REPORTER;
pl(SQLERRM);
pl('** REVERTING TO DEFAULT REPORTER **');
END IF;
ELSE
RAISE;
END IF;
call(proc, param, params, force_reporter => DEFAULT_REPORTER);
END;
PROCEDURE call(proc IN VARCHAR2,
failover IN BOOLEAN := TRUE)
IS
BEGIN
call(proc => proc,
param => '',
params => 0,
failover => failover);
END;
PROCEDURE use(reporter IN VARCHAR2)
IS
BEGIN
g_reporter := NVL(reporter, DEFAULT_REPORTER);
g_actual := g_reporter;
END;
FUNCTION using RETURN VARCHAR2
IS
BEGIN
RETURN g_reporter;
END;

PROCEDURE open
IS
BEGIN
g_actual := g_reporter;
call('open', failover => FALSE);
END;

PROCEDURE pl (str IN VARCHAR2)
IS
BEGIN
call('pl', str);
END;

PROCEDURE pl (bool IN BOOLEAN)
IS
BEGIN
pl (Utplsql.bool2vc (bool));
END;

PROCEDURE before_results(run_id IN utr_outcome.run_id%TYPE)
IS
BEGIN
call('before_results', run_id);
END;
PROCEDURE show_failure(rec_result IN utr_outcome%ROWTYPE)
IS
BEGIN
outcome := rec_result;
call('show_failure');
END;
PROCEDURE show_result(rec_result IN utr_outcome%ROWTYPE)
IS
BEGIN
outcome := rec_result;
call('show_result');
END;
PROCEDURE after_results(run_id IN utr_outcome.run_id%TYPE)
IS
BEGIN
call('after_results', run_id);
END;
PROCEDURE before_errors(run_id IN utr_error.run_id%TYPE)
IS
BEGIN
call('before_errors', run_id);
END;
PROCEDURE show_error(rec_error IN utr_error%ROWTYPE)
IS
BEGIN
error := rec_error;
call('show_error');
END;
PROCEDURE after_errors(run_id IN utr_error.run_id%TYPE)
IS
BEGIN
call('after_errors', run_id);
END;
PROCEDURE close
IS
BEGIN
call('close');
END;

BEGIN

g_reporter := NVL(utconfig.getreporter, DEFAULT_REPORTER);
g_actual := g_reporter;
END;
/

+ 0
- 0
it/it-projects/plugins/project/src/python/__init__.py View File


+ 92
- 0
it/it-projects/plugins/project/src/python/badfortune.py View File

@@ -0,0 +1,92 @@

# fortune.py -- chooses a random fortune, as the fortune(8) program in
# the BSD-games package does
#
# Copyright (c) 2010, Andrew M. Kuchling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import struct, random, string

# C long variables are different sizes on 32-bit and 64-bit machines,
# so we have to measure how big they are on the machine where this is running.
LONG_SIZE = struct.calcsize('L')
is_64_bit = (LONG_SIZE == 8)

def get(filename):
"Select a random quotation, using a pregenerated .dat file"

# First, we open the .dat file, and read the header information.
# The C structure containing this info looks like:
## typedef struct { /* information table */
## #define VERSION 1
## unsigned long str_version; /* version number */
## unsigned long str_numstr; /* # of strings in the file */
## unsigned long str_longlen; /* length of longest string */
## unsigned long str_shortlen; /* length of shortest string */
## #define STR_RANDOM 0x1 /* randomized pointers */
## #define STR_ORDERED 0x2 /* ordered pointers */
## #define STR_ROTATED 0x4 /* rot-13'd text */
## unsigned long str_flags; /* bit field for flags */
## unsigned char stuff[4]; /* long aligned space */
## #define str_delim stuff[0] /* delimiting character */
## } STRFILE;

datfile = open(filename+'.dat', 'r')
data = datfile.read(5 * LONG_SIZE)
if is_64_bit:
v1, v2, n1, n2, l1, l2, s1, s2, f1, f2 = struct.unpack('!10L', data)
version = v1 + (v2 << 32)
numstr = n1 + (n2 << 32)
longlen = l1 + (l2 << 32)
shortlen = s1 + (s2 << 32)
flags = f1 + (f2 << 32)
else:
version, numstr, longlen, shortlen, flags = struct.unpack('5l', data)

delimiter = datfile.read(1)
datfile.read(3) # Throw away padding bytes
if is_64_bit: datfile.read(4) # 64-bit machines align to 8 bytes

# Pick a random number
r = random.randint(0, numstr)
datfile.seek(LONG_SIZE * r, 1) # Seek to the chosen pointer
data = datfile.read(LONG_SIZE * 2)

if is_64_bit:
s1, s2, e1, e2 = struct.unpack('!4L', data)
start, end = s1 + (s2 << 32), e1 + (e2 << 32)
else:
start, end = struct.unpack('!ll', data)
datfile.close()

file = open(filename, 'r')
file.seek(start)
quotation = file.read(end-start)
L=string.split(quotation, '\n')
while string.strip(L[-1]) == delimiter or string.strip(L[-1]) == "":
L=L[:-1]
return string.join(L, '\n')

if __name__ == '__main__':
import sys
if len(sys.argv) == 1:
print 'Usage: fortune.py <filename>'
sys.exit()
print get(sys.argv[1])

+ 1
- 0
it/it-projects/plugins/project/src/python/directory/file_in_directory.py View File

@@ -0,0 +1 @@
lst = []

+ 8
- 0
it/it-projects/plugins/project/src/python/hasissues.py View File

@@ -0,0 +1,8 @@
class MyClass:
while True:
return False #Noncompliant

def __enter__(self):
pass
def __exit__(self, exc_type, exc_val): # Noncompliant
pass

+ 0
- 0
it/it-projects/plugins/project/src/python/package/__init__.py View File


+ 1
- 0
it/it-projects/plugins/project/src/python/package/file_in_package.py View File

@@ -0,0 +1 @@
dictionary = {}

+ 0
- 0
it/it-projects/plugins/project/src/python/samples/__init__.py View File


+ 92
- 0
it/it-projects/plugins/project/src/python/samples/fortune.py View File

@@ -0,0 +1,92 @@

# fortune.py -- chooses a random fortune, as the fortune(8) program in
# the BSD-games package does
#
# Copyright (c) 2010, Andrew M. Kuchling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import struct, random, string

# C long variables are different sizes on 32-bit and 64-bit machines,
# so we have to measure how big they are on the machine where this is running.
LONG_SIZE = struct.calcsize('L')
is_64_bit = (LONG_SIZE == 8)

def get(filename):
"Select a random quotation, using a pregenerated .dat file"

# First, we open the .dat file, and read the header information.
# The C structure containing this info looks like:
## typedef struct { /* information table */
## #define VERSION 1
## unsigned long str_version; /* version number */
## unsigned long str_numstr; /* # of strings in the file */
## unsigned long str_longlen; /* length of longest string */
## unsigned long str_shortlen; /* length of shortest string */
## #define STR_RANDOM 0x1 /* randomized pointers */
## #define STR_ORDERED 0x2 /* ordered pointers */
## #define STR_ROTATED 0x4 /* rot-13'd text */
## unsigned long str_flags; /* bit field for flags */
## unsigned char stuff[4]; /* long aligned space */
## #define str_delim stuff[0] /* delimiting character */
## } STRFILE;

datfile = open(filename+'.dat', 'r')
data = datfile.read(5 * LONG_SIZE)
if is_64_bit:
v1, v2, n1, n2, l1, l2, s1, s2, f1, f2 = struct.unpack('!10L', data)
version = v1 + (v2 << 32)
numstr = n1 + (n2 << 32)
longlen = l1 + (l2 << 32)
shortlen = s1 + (s2 << 32)
flags = f1 + (f2 << 32)
else:
version, numstr, longlen, shortlen, flags = struct.unpack('5l', data)

delimiter = datfile.read(1)
datfile.read(3) # Throw away padding bytes
if is_64_bit: datfile.read(4) # 64-bit machines align to 8 bytes

# Pick a random number
r = random.randint(0, numstr)
datfile.seek(LONG_SIZE * r, 1) # Seek to the chosen pointer
data = datfile.read(LONG_SIZE * 2)

if is_64_bit:
s1, s2, e1, e2 = struct.unpack('!4L', data)
start, end = s1 + (s2 << 32), e1 + (e2 << 32)
else:
start, end = struct.unpack('!ll', data)
datfile.close()

file = open(filename, 'r')
file.seek(start)
quotation = file.read(end-start)
L=string.split(quotation, '\n')
while string.strip(L[-1]) == delimiter or string.strip(L[-1]) == "":
L=L[:-1]
return string.join(L, '\n')

if __name__ == '__main__':
import sys
if len(sys.argv) == 1:
print 'Usage: fortune.py <filename>'
sys.exit()
print get(sys.argv[1])

+ 203
- 0
it/it-projects/plugins/project/src/python/samples/letters.py View File

@@ -0,0 +1,203 @@

#
# Copyright (c) 2010, Andrew M. Kuchling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import random, string

# Logic game
# From a program by Judith Haris, John Swets, and Wallace Feurzeig
# Reference: The Secret Guide to Computers, by Russ Walter, 18th ed 1993.
# Written in Python by A.M. Kuchling (amk@amk.ca)

# For each letter, we need the various characteristics:
# (curves, loose ends, obliques, horizontals, verticals).
# There should really be a sample character set for the user to look
# at; otherwise, there are ambiguities. For example, does B have
# horizontals? Does D? How about P and R?

# There's a bug lurking in this data! Can you catch it?
# (See the bottom of the program for the answer.)

letter_stats={'a': (0, 2, 2, 1, 0), 'b':(2, 0, 0, 3, 1),
'c': (1, 2, 0, 0, 0), 'd':(1, 0, 0, 0, 1),
'e': (0, 3, 0, 3, 1), 'f':(0, 3, 0, 2, 1),
'g': (1, 2, 0, 1, 1), 'h':(0, 4, 0, 1, 2),
'i': (0, 2, 0, 0, 1), 'j':(1, 2, 0, 0, 1),
'k': (0, 4, 2, 0, 1), 'l':(0, 2, 0, 1, 1),
'm': (0, 2, 2, 0, 2), 'n':(0, 2, 1, 0, 2),
'o': (1, 0, 0, 0, 0), 'p':(1, 1, 0, 2, 1),
'q': (1, 2, 1, 0, 0), 'r':(1, 2, 1, 0, 1),
's': (1, 2, 0, 0, 0), 't':(0, 3, 0, 1, 1),
'u': (1, 2, 0, 0, 2), 'v':(0, 2, 2, 0, 0),
'w': (0, 2, 4, 0, 0), 'x':(0, 4, 2, 0, 0),
'y': (0, 3, 2, 0, 1), 'z':(0, 2, 1, 2, 0)}

# We'll define constants for the various statistics; each constant is
# equal to the position of the statistic in the tuples in
#letter_stats.
CURVES=0 ; LOOSE_ENDS=1 ; OBLIQUES=2 ; HORIZONTALS=3 ; VERTICALS=4

# This dictionary is used to map questions to corresponding
# statistics. Note that different keys can map to the same value;
# for example, 'obliques' and 'diagonals' both map to the OBLIQUES constant.
questions={'curves':CURVES, 'looseends':LOOSE_ENDS,
'obliques':OBLIQUES, 'diagonals':OBLIQUES,
'horizontals':HORIZONTALS, 'verticals':VERTICALS}

# Play a single game

def play_once():
# Choose a random number between 0 and 26, inclusive.
choice=26*random.random()
# Convert the numeric choice to a letter: 0->a, 1->b, etc.
choice=chr(ord('a')+choice)

#choice=raw_input("What should I choose?") # (for debugging)

# We'll track how many possibilities the user still has available.
# Start with all of the letters.
possibilities=string.lower("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# We'll also track which questions have been asked, and chide the
# user when he repeats a question.
asked=[]

# Loop forever; the play_once() function will exit by hitting a
# 'return' statement inside the loop.
while (1):
try:
#print possibilities # (for debugging)

# Get input from the user
query=raw_input('Next? ')
# Convert the input to lowercase
query=string.lower(query)
# Remove all non-letter characters
query=filter(lambda x: x in string.lowercase, query)
# Remove whitespace
query=string.strip(query)

except (EOFError, KeyboardInterrupt):
# End-Of-File : the user
print '\nOK; give up if you like.'
return

if len(query)==1:
# The query is one character long, so it's a guess
if query not in possibilities:
print ("Wrong! That guess is inconsistent "
"with the information you've been given.\n"
"I think you made that guess just to see "
"what I would say.")
elif len(possibilities)>1:
print "You don't have enough information yet."
# Temporarily remove the user's guess from
# possibilities, and pick a random letter.
temp=filter(lambda x, query=query: x!=query, possibilities)
r=int(random.random()*len(temp))
print "How do you know it isn't", temp[r]+',',
print "for example?"
else:
# query is in possibilities, and
# len(possibilities)==1, so the user is right.
print "Yes, you've done it. Good work!" ; return
elif questions.has_key(query):
# Get the field of the letter_stats tuple to compare.
field=questions[query]
# Determine the answer for the computer's letter
result=letter_stats[choice][field]
original_length=len(possibilities)

# Exclude possibilities that don't match those of the
# mystery letter.
# filter(func, sequence) calls func() on each element in
# the sequence, and returns a new sequence object
# containing only elements for which func() returned true.
# For strings, each character is an element. Instead of
# defining a formal function, a lambda is used to create
# an anonymous function (one without a name).
# Various other things required by the function are set
# as default arguments, so they're accessible inside the
# scope of the anonymous function.
possibilities=filter(lambda letter, letter_stats=letter_stats,
field=field, result=result:
letter_stats[letter][field]==result,
possibilities)
new_length=len(possibilities)
if field in asked:
print "You asked me that already."
print "The answer is the same as before:",
else: asked.append(field) # Note that this question was asked.
print str(result)+'.'
if (original_length==new_length):
print 'That was a wasted question; it did not exclude any possibilities.'
elif (new_length<original_length/2 or new_length==1):
print "Good question."
else:
print "I don't understand the question."

# Print the instructions
print """This is a guessing game about capital letters.
You can ask various questions about the features of the letter:
curves, loose ends, obliques (or diagonals), horizontals, verticals.
To make a guess, just enter the letter of your choice.

Sample transcript:
Next? curves?
1.
Good question.
Next? c
You don't have enough information yet.
How do you know it isn't s, for example?
Next? horizontals?
0.
Next? s
You don't have enough information yet.
How do you know it isn't c, for example?
"""

# Play a single game
play_once()
raw_input("Press Return>")

# The solution to the bug-hunt is below...











# It's not a bug that the Python interpreter can catch; instead, it's
# a specification bug:
#
# 'C' and 'S' both have the same stats: 1 curve, 2 loose ends,
# and no obliques, horizontals, or verticals. If either C or S is
# chosen as the computer's letter, the user can never get the right
# answer, because he/she can't narrow down the possibilities to just
# one! To fix this, you'd have to add another statistic, like
# number of intersections or number of closed loops. However, the
# statistic would have to be *different* for 'C' and 'S', and neither
# of those two suggestions qualify. Can you think of a property to
# distinguish between the two letters?

+ 100
- 0
it/it-projects/plugins/project/src/python/samples/strfile.py View File

@@ -0,0 +1,100 @@

# strfile.py -- write an index file for a fortune file, as the strfile(8)
# program in the BSD-games package does
#
# Copyright (c) 2010, Andrew M. Kuchling
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

import struct, string, sys

if len(sys.argv)==1:
print "Usage: strfile.py <filename>"
sys.exit()

# C long variables are different sizes on 32-bit and 64-bit machines,
# so we have to measure how big they are on the machine where this is running.
LONG_SIZE = struct.calcsize('L')
is_64_bit = (LONG_SIZE == 8)

delimiter = '%' # The standard delimiter

filename = sys.argv[1]
input = open(filename, 'r')
output = open(filename + '.dat', 'w')
output.seek(LONG_SIZE * 6) # Skip over the header for now

# Output a 32- or 64-bit integer

def write_long(x):
if is_64_bit:
output.write( struct.pack("!LL", x & 0xffffFFFFL, x >> 32) )
else:
output.write( struct.pack("!L", x) )

write_long(0) # Write the first pointer

# We need to track various statistics: the longest and shortest
# quotations, and their number

shortest = sys.maxint ; longest = 0
numstr = 0
quotation = ""

while (1):
L=input.readline() # Get a line
if L=="": break # Check for end-of-file
if string.strip(L) != delimiter:
# We haven't come to the end yet, so we just add the line to
# the quotation we're building and continue
quotation = quotation + L ; continue

# If there's a leading % in the file, the first quotation will be
# empty; we'll just ignore it
if quotation == "": continue

# Update the shortest and longest variables
shortest = min(shortest, len(quotation) )
longest = max(longest, len(quotation) )

# Output the current file pointer
write_long( input.tell() )
numstr = numstr + 1
quotation = "" # Reset the quotation to null

# To simplify the programming, we'll assume there's a trailing % line
# in the file, with no quotation following.
assert quotation == ""

input.close()

# We're done, so rewind to the beginning of the file and write the header
output.seek(0)
write_long( 1 ) # Version
write_long(numstr) # Number of strings
write_long(longest) # Longest string length
write_long(shortest) # Shortest string length
write_long(0) # Flags; we'll set them to zero
output.write(delimiter + '\0'*(LONG_SIZE-1))
output.close()

print '''"%s.dat" created
There were %i strings
Longest string: %i bytes
Shortest string: %i bytes''' % (filename, numstr, longest, shortest)

+ 53
- 0
it/it-projects/plugins/project/src/rpg/MYPROGRAM.rpg View File

@@ -0,0 +1,53 @@
123456789012 C* Expressions in Extended Factor 2 syntax
123456789012 C IF A=X OR A=Y AND A=Z
123456789012 C AND B=Y
123456789012 C READ Y
123456789012 C ENDIF
123456789012 C IF A=X OR A=Y AND A=Z
123456789012 C AND B=Y OR B=Z
123456789012 C READ Y
123456789012 C ENDIF
123456789012 C* Expressions composed over several operations in IF
123456789012 C A IFEQ X
123456789012 C A OREQ Y
123456789012 C A ANDEQ Z
123456789012 C B ANDEQ Y
123456789012 C READ Y
123456789012 C ENDIF
123456789012 C A IFEQ X
123456789012 C A OREQ Y
123456789012 C A ANDEQ Z
123456789012 C B ANDEQ Y
123456789012 C B OREQ Z
123456789012 C READ Y
123456789012 C ENDIF
123456789012 C* Expressions composed over several operations in DO
123456789012 C A DOUEQ X
123456789012 C A OREQ Y
123456789012 C A ANDEQ Z
123456789012 C B ANDEQ Y
123456789012 C READ Y
123456789012 C END
123456789012 C A DOUEQ X
123456789012 C A OREQ Y
123456789012 C A ANDEQ Z
123456789012 C B ANDEQ Y
123456789012 C B OREQ Z
123456789012 C READ Y
123456789012 C END
123456789012 C* Expressions composed over several operations in WHEN
123456789012 C SELECT
123456789012 C A WHENEQ X
123456789012 C A OREQ Y
123456789012 C A ANDEQ Z
123456789012 C B ANDEQ Y
123456789012 C READ Y
123456789012 C END
123456789012 C SELECT
123456789012 C A WHENEQ X
123456789012 C A OREQ Y
123456789012 C A ANDEQ Z
123456789012 C B ANDEQ Y
123456789012 C B OREQ Z
123456789012 C READ Y
123456789012 C END

+ 10
- 0
it/it-projects/plugins/project/src/swift/example.swift View File

@@ -0,0 +1,10 @@

let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]

func backwards(s1: String, s2: String) -> Bool {
return s1 > s2
}

var reversed = sorted(names, backwards);

if (true) { print(reversed) }

+ 67
- 0
it/it-projects/plugins/project/src/vb/Info.frm View File

@@ -0,0 +1,67 @@
VERSION 5.00
Begin VB.Form frmInfo
BorderStyle = 3 'Fixed Dialog
Caption = "Info"
ClientHeight = 3750
ClientLeft = 45
ClientTop = 330
ClientWidth = 6270
Icon = "Info.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3750
ScaleWidth = 6270
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.CommandButton cmdOK
Caption = "&OK"
Default = -1 'True
Height = 375
Left = 5100
TabIndex = 1
Top = 3300
Width = 1095
End
Begin VB.TextBox txtGPL
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 3075
Left = 120
Locked = -1 'True
MultiLine = -1 'True
TabIndex = 0
Text = "Info.frx":000C
Top = 120
Width = 6015
End
End
Attribute VB_Name = "frmInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
' --- GPL ---
'
' Copyright (C) 1999 SAP AG
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation; either version 2
' of the License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'
' --- GPL ---
Option Explicit

Private Sub cmdOK_Click()
Unload Me
End Sub

+ 166
- 0
it/it-projects/plugins/project/src/vb/Registry.bas View File

@@ -0,0 +1,166 @@
Attribute VB_Name = "modRegistry"
' --- GPL ---
'
' Copyright (C) 1999 SAP AG
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation; either version 2
' of the License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'
' --- GPL ---
Option Explicit

'Structures Needed For Registry Prototypes
Public Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Boolean
End Type

Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type

'Registry Function Prototypes
Public Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" ( _
ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal ulOptions As Long, _
ByVal samDesired As Long, _
phkResult As Long) As Long

Public Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" ( _
ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal Reserved As Long, _
ByVal lpClass As String, _
ByVal dwOptions As Long, _
ByVal samDesired As Long, _
lpSecurityAttributes As SECURITY_ATTRIBUTES, _
phkResult As Long, _
lpdwDisposition As Long) As Long

Public Declare Function RegQueryValueExNull Lib "advapi32.dll" Alias "RegQueryValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal lpReserved As Long, _
lpType As Long, _
ByVal lpData As Long, _
lpcbData As Long) As Long

Public Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal lpReserved As Long, _
lpType As Long, _
ByVal lpData As String, _
lpcbData As Long) As Long
Public Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal lpReserved As Long, _
lpType As Long, _
lpData As Long, _
lpcbData As Long) As Long

Public Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
ByVal lpValue As String, _
ByVal cbData As Long) As Long
Public Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
lpValue As Long, _
ByVal cbData As Long) As Long

Public Declare Function RegEnumKeyEx Lib "advapi32.dll" Alias "RegEnumKeyExA" ( _
ByVal hKey As Long, _
ByVal dwIndex As Long, _
ByVal lpName As String, _
lpcbName As Long, _
ByVal lpReserved As Long, _
ByVal lpClass As String, _
lpcbClass As Long, _
lpftLastWriteTime As FILETIME) As Long

Public Declare Function RegEnumValue Lib "advapi32.dll" Alias "RegEnumValueA" ( _
ByVal hKey As Long, _
ByVal dwIndex As Long, _
ByVal lpValueName As String, _
lpcbValueName As Long, _
ByVal lpReserved As Long, _
lpType As Long, _
lpData As Any, _
lpcbData As Long) As Long

Public Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" ( _
ByVal hKey As Long, _
ByVal lpSubKey As String) As Long

Public Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String) As Long

Public Declare Function RegCloseKey Lib "advapi32" ( _
ByVal hKey As Long) As Long

'
''masks for the predefined standard access types
'Private Const STANDARD_RIGHTS_ALL = &H1F0000
'Private Const SPECIFIC_RIGHTS_ALL = &HFFFF
'
''Define severity codes
'
''Public Const ERROR_ACCESS_DENIED = 5
''
''Global Const ERROR_NONE = 0
''Global Const ERROR_BADDB = 1
''Global Const ERROR_CANTOPEN = 3
''Global Const ERROR_CANTREAD = 4
''Global Const ERROR_CANTWRITE = 5
''Global Const ERROR_OUTOFMEMORY = 6
''Global Const ERROR_INVALID_PARAMETER = 7
''Global Const ERROR_ACCESS_DENIED = 8
''Global Const ERROR_INVALID_PARAMETERS = 87
''Global Const ERROR_NO_MORE_ITEMS = 259

Public Type ByteValue
b(1024) As Byte
End Type

Public Type LongValue
l As Long
End Type

Public Function BytesToString(bValue As ByteValue) As String
Dim s As String
Dim i As Integer
s = StrConv(bValue.b(), vbUnicode)
i = InStr(s, Chr(0)) - 1
BytesToString = Left(s, i)
End Function

Public Function BytesToLong(bValue As ByteValue) As Long
Dim lValue As LongValue
LSet lValue = bValue
BytesToLong = lValue.l
End Function


+ 428
- 0
it/it-projects/plugins/project/src/vb/Registry.cls View File

@@ -0,0 +1,428 @@
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Registry"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' --- GPL ---
'
' Copyright (C) 1999 SAP AG
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation; either version 2
' of the License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
'
' --- GPL ---
Option Explicit

Public Enum RegistryHKeyConstants
HKEY_CLASSES_ROOT = &H80000000
HKEY_CURRENT_USER = &H80000001
HKEY_LOCAL_MACHINE = &H80000002
HKEY_USERS = &H80000003
HKEY_PERFORMANCE_DATA = &H80000004
HKEY_CURRENT_CONFIG = &H80000005
HKEY_DYN_DATA = &H80000006
End Enum

Public Enum RegistryTypeConstants
REG_NONE = (0) 'No value type
REG_SZ = (1) 'Unicode nul terminated string
' REG_EXPAND_SZ = (2) 'Unicode nul terminated string w/enviornment var
' REG_BINARY = (3) 'Free form binary
REG_DWORD = (4) '32-bit number
' REG_DWORD_LITTLE_ENDIAN = (4) '32-bit number (same as REG_DWORD)
' REG_DWORD_BIG_ENDIAN = (5) '32-bit number
' REG_LINK = (6) 'Symbolic Link (unicode)
' REG_MULTI_SZ = (7) 'Multiple Unicode strings
' REG_RESOURCE_LIST = (8) 'Resource list in the resource map
' REG_FULL_RESOURCE_DESCRIPTOR = (9) 'Resource list in the hardware description
' REG_RESOURCE_REQUIREMENTS_LIST = (10)
End Enum

Public Enum RegistryAccessConstants
KEY_QUERY_VALUE = &H1
KEY_SET_VALUE = &H2
KEY_CREATE_SUB_KEY = &H4
KEY_ENUMERATE_SUB_KEYS = &H8
KEY_NOTIFY = &H10
KEY_CREATE_LINK = &H20
KEY_ALL_ACCESS = &H3F
End Enum

Public Enum RegistryErrorConstants
ERROR_SUCCESS = 0
ERROR_BADKEY = 2
ERROR_OUTOFMEMORY = 6
ERROR_MORE_DATA = 234
ERROR_NO_MORE_ITEMS = 259
End Enum

Public Enum RegistryVolatileConstants
REG_OPTION_NON_VOLATILE = 0&
REG_OPTION_VOLATILE = &H1
End Enum

Public Enum RegistryDispositionConstants
REG_CREATED_NEW_KEY = &H1
REG_OPENED_EXISTING_KEY = &H2
End Enum

Private oKeys As Keys

Private bShowErrors As Boolean
Private bRaiseErrors As Boolean
'
' Public Properties
'
Public Property Get Keys() As Keys
If oKeys Is Nothing Then
Set oKeys = New Keys
With oKeys
Set .Registry = Me
Set .Parent = Me
.Root = True
End With
End If
Set Keys = oKeys
End Property

Public Property Get ShowErrors() As Boolean
ShowErrors = bShowErrors
End Property
Public Property Let ShowErrors(ByVal NewVal As Boolean)
bShowErrors = NewVal
End Property

Public Property Get RaiseErrors() As Boolean
RaiseErrors = bRaiseErrors
End Property
Public Property Let RaiseErrors(ByVal NewVal As Boolean)
bRaiseErrors = NewVal
End Property
'
' Public Sub/Function
'
' Base Functions
'
Public Function OpenKey(ByVal hKey As RegistryHKeyConstants, _
ByVal Path As String, _
ByVal Access As RegistryAccessConstants, _
Key As Long) As Boolean
Dim lRC As Long
OpenKey = False
lRC = RegOpenKeyEx(hKey, Path, 0&, Access, Key)
If lRC = ERROR_SUCCESS Then
OpenKey = True
Else
HandleError lRC, Path
End If
End Function

Public Function CreateKey(ByVal hKey As RegistryHKeyConstants, _
ByVal Path As String, _
ByVal Volatile As RegistryVolatileConstants, _
ByVal Access As RegistryAccessConstants, _
Key As Long, _
Disposition As Long) As Boolean

Dim lRC As Long
Dim saKey As SECURITY_ATTRIBUTES
CreateKey = False
lRC = RegCreateKeyEx(hKey, Path, 0, "", Volatile, Access, saKey, Key, Disposition)
If lRC = ERROR_SUCCESS Then
CreateKey = True
Else
HandleError lRC, Path
End If
End Function

Public Function DeleteKey(ByVal hKey As RegistryHKeyConstants, _
ByVal Path As String) As Boolean

Dim lRC As Long
DeleteKey = False
lRC = RegDeleteKey(hKey, Path)
If lRC = ERROR_SUCCESS Then
DeleteKey = True
Else
HandleError lRC, Path
End If
End Function

Public Function CloseKey(ByVal Path, _
Key As Long) As Boolean

Dim lRC As Long
CloseKey = False
lRC = RegCloseKey(Key)
If lRC = ERROR_SUCCESS Then
Key = 0
CloseKey = True
Else
HandleError lRC, Path
End If
End Function

Public Function QueryValueNull(ByVal hKey As Long, _
ByVal Name As String, _
ValueType As RegistryTypeConstants, _
ValueLen As Long) As Boolean
Dim lRC As Long

QueryValueNull = False
lRC = RegQueryValueExNull(hKey, Name, 0&, ValueType, 0&, ValueLen)
If lRC = ERROR_SUCCESS Then
QueryValueNull = True
Else
HandleError lRC, Name
End If
End Function

Public Function QueryValueString(ByVal hKey As Long, _
ByVal Name As String, _
Value As String, _
ValueLen As Long) As Boolean
Dim lRC As Long

QueryValueString = False
Value = String(ValueLen, 0)
lRC = RegQueryValueExString(hKey, Name, 0&, REG_SZ, Value, ValueLen)
If lRC = ERROR_SUCCESS Then
Value = Left(Value, ValueLen - 1)
QueryValueString = True
Else
HandleError lRC, Name
End If
End Function

Public Function QueryValueLong(ByVal hKey As Long, _
ByVal Name As String, _
Value As Long) As Boolean
Dim lRC As Long
Dim lValueLen As Long
QueryValueLong = False
Value = 0
lRC = RegQueryValueExLong(hKey, Name, 0&, REG_DWORD, Value, 4)
If lRC = ERROR_SUCCESS Then
QueryValueLong = True
Else
HandleError lRC, Name
End If
End Function

Public Function SetValueString(ByVal hKey As Long, _
ByVal Name As String, _
ByVal Value As String) As Boolean

Dim lRC As Long
SetValueString = False
Value = Value & Chr(0)
lRC = RegSetValueExString(hKey, Name, 0&, REG_SZ, Value, Len(Value))
If lRC = ERROR_SUCCESS Then
SetValueString = True
Else
HandleError lRC, Name
End If
End Function

Public Function SetValueLong(ByVal hKey As Long, _
ByVal Name As String, _
ByVal Value As Long) As Boolean

Dim lRC As Long
SetValueLong = False
lRC = RegSetValueExLong(hKey, Name, 0&, REG_DWORD, Value, 4)
If lRC = ERROR_SUCCESS Then
SetValueLong = True
Else
HandleError lRC, Name
End If
End Function

Public Function DeleteValue(ByVal hKey As Long, _
ByVal Name As String) As Boolean

Dim lRC As Long

DeleteValue = False
lRC = RegDeleteValue(hKey, Name)
If lRC = ERROR_SUCCESS Then
DeleteValue = True
Else
HandleError lRC, Name
End If
End Function
'
'
'
Public Function Check(ByVal WithSubKeys As Boolean, _
ByVal WithValues As Boolean) As Boolean
Dim oKey As Key
Check = False
For Each oKey In Keys
If Not oKey.Check(WithSubKeys, WithValues) Then
Exit Function
End If
Next
Check = True
End Function

Public Function Create(ByVal WithSubKeys As Boolean, _
ByVal WithValues As Boolean) As Boolean

Dim oKey As Key
Create = False
For Each oKey In Keys
If Not oKey.Create(WithSubKeys, WithValues) Then
Exit Function
End If
Next
Create = True
End Function

Public Function QueryValues(ByVal WithSubKeys As Boolean) As Boolean
Dim oKey As Key
QueryValues = False
For Each oKey In Keys
If Not oKey.QueryValues(WithSubKeys) Then
Exit Function
End If
Next
QueryValues = True
End Function

Public Function SetValues(ByVal WithSubKeys As Boolean) As Boolean
Dim oKey As Key
SetValues = False
For Each oKey In Keys
If Not oKey.SetValues(WithSubKeys) Then
Exit Function
End If
Next
SetValues = True
End Function

Public Function EnumKeys(ByVal WithSubKeys As Boolean, _
ByVal WithValues As Boolean) As Boolean

Dim oKey As Key
EnumKeys = False
For Each oKey In Keys
If Not oKey.EnumKeys(WithSubKeys, WithValues) Then
Exit Function
End If
Next
EnumKeys = True
End Function

Public Function FindKeyByPath(ByVal WithSubKeys As Boolean, _
ByVal FindPath As String) As Key
Dim oKey As Key
Set FindKeyByPath = Nothing
For Each oKey In Keys
If FindPath = oKey.Path Then
Set FindKeyByPath = oKey
Exit Function
End If
If WithSubKeys Then
Set FindKeyByPath = oKey.FindKeyByPath(WithSubKeys, FindPath)
End If
Next
End Function

Friend Sub HandleError(ByVal RC As Long, ByVal Text As String)
Dim sMsg As String
If bShowErrors Then
sMsg = "Error: " & ErrorText(RC) & ". " & Text
MsgBox sMsg, vbExclamation
End If
End Sub
'
' Private Sub/Function
'
Private Sub Class_Initialize()
'Debug.Print "INIT Registry"
Set oKeys = Nothing
bShowErrors = True
bRaiseErrors = False
End Sub

Private Sub Class_Terminate()
'Debug.Print "TERM Registry"
End Sub

Private Function ErrorText(ByVal lRC As Long) As String
Dim s As String
Select Case lRC
Case ERROR_BADKEY: s = "Bad key"
Case ERROR_MORE_DATA: s = "More data"
Case ERROR_OUTOFMEMORY: s = "Out of memory"
Case ERROR_NO_MORE_ITEMS: s = "No more items"
Case Else: s = "RC=" & CStr(lRC)
End Select
ErrorText = s
End Function


+ 48
- 0
it/it-projects/plugins/project/src/web/sample.xhtml View File

@@ -0,0 +1,48 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<f:metadata>
<f:viewParam name="user" value="#{userEdit.user}" converter="#{userConvertor}" />
<f:event listener="#{userEdit.preRenderView()}" type="preRenderView"/>
</f:metadata>
<h:head>
<title>User list</title>
</h:head>
<h:body>
<h:messages />
<h:form>
<h:panelGrid columns="2">
<f:facet name="header">User</f:facet>
<h:outputLabel value="Id" rendered="#{!empty userEdit.user.id}" />
<h:outputLabel value="#{userEdit.user.id}" rendered="#{!empty userEdit.user.id}" />
<h:outputLabel for="firstName" value="First name" />
<h:inputText id="firstName" value="#{userEdit.user.firstName}" label="First name" />
<h:outputLabel for="lastName" value="Last name" />
<h:inputText id="lastName" value="#{userEdit.user.lastName}" label="Last name" />
<h:outputLabel for="birthDay" value="Birth day" />
<h:inputText id="birthDay" value="#{userEdit.user.birthday}" label="Birth day">
<f:convertDateTime pattern="dd-MM-yyyy"/>
</h:inputText>
<h:outputLabel for="email" value="Email" />
<h:inputText id="email" value="#{userEdit.user.email}" />
<h:commandButton action="#{userEdit.saveUser}" value="Submit" />
<h:button outcome="index.xhtml" value="Cancel" />
</h:panelGrid>
</h:form>
</h:body>
</html>

BIN
it/it-projects/plugins/project/target/classes/foo/Foo.class View File


BIN
it/it-projects/plugins/project/target/classes/foo/Simplest.class View File


BIN
it/it-projects/plugins/project/target/classes/foo/Simplest2.class View File


BIN
it/it-projects/plugins/project/target/classes/foo/Simplest3.class View File


BIN
it/it-projects/plugins/project/target/it-all-lang-1.0-SNAPSHOT.jar View File


+ 71
- 0
it/it-projects/plugins/project/target/js/lcov.dat View File

@@ -0,0 +1,71 @@
SF:src/js/Person.js
DA:2,1
DA:3,2
DA:4,2
DA:5,2
DA:8,1
DA:11,2
end_of_record
SF:src/js/com/company/Car.js
DA:1,1
DA:2,3
DA:3,3
DA:4,3
DA:5,3
DA:6,3
DA:9,1
DA:12,1
DA:16,1
DA:17,0
DA:18,1
DA:19,1
DA:21,0
DA:26,0
DA:27,0
DA:31,0
DA:32,0
DA:36,1
DA:37,0
DA:38,0
DA:39,0
DA:41,1
DA:42,1
DA:47,0
end_of_record
SF:src/jscom/company/Truck.js
DA:1,1
DA:2,0
DA:3,0
DA:4,0
DA:5,0
DA:6,0
DA:9,1
DA:12,0
DA:16,0
DA:17,0
DA:18,0
DA:19,0
DA:21,0
end_of_record
SF:src/jscom/company/Vehicle.js
DA:9,1
DA:10,0
DA:11,0
DA:12,0
DA:13,0
DA:14,0
DA:22,1
DA:25,0
DA:29,0
DA:30,0
DA:31,0
DA:32,0
DA:34,0
DA:39,0
DA:40,0
DA:41,0
DA:42,0
DA:44,0
DA:45,0
DA:50,0
end_of_record

+ 101
- 0
it/it-projects/plugins/project/target/php/phpunit.coverage.xml View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1394164581">
<project timestamp="1394164581">
<file name="src/Math.php">
<class name="PhpUnderControl_Example_Math" namespace="global" fullPackage="Example" package="Example">
<metrics methods="4" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="84" coveredstatements="2" elements="88" coveredelements="4"/>
</class>
<line num="46" type="stmt" count="0"/>
<line num="69" type="method" name="add" crap="1" count="1"/>
<line num="71" type="stmt" count="1"/>
<line num="82" type="method" name="sub" crap="1" count="10"/>
<line num="84" type="stmt" count="10"/>
<line num="90" type="method" name="div" crap="132" count="0"/>
<line num="92" type="stmt" count="0"/>
<line num="93" type="stmt" count="0"/>
<line num="94" type="stmt" count="0"/>
<line num="95" type="stmt" count="0"/>
<line num="96" type="stmt" count="0"/>
<line num="98" type="stmt" count="0"/>
<line num="99" type="stmt" count="0"/>
<line num="100" type="stmt" count="0"/>
<line num="101" type="stmt" count="0"/>
<line num="103" type="stmt" count="0"/>
<line num="105" type="stmt" count="0"/>
<line num="107" type="stmt" count="0"/>
<line num="108" type="stmt" count="0"/>
<line num="110" type="stmt" count="0"/>
<line num="111" type="stmt" count="0"/>
<line num="112" type="stmt" count="0"/>
<line num="114" type="stmt" count="0"/>
<line num="115" type="stmt" count="0"/>
<line num="117" type="stmt" count="0"/>
<line num="118" type="stmt" count="0"/>
<line num="120" type="stmt" count="0"/>
<line num="121" type="stmt" count="0"/>
<line num="122" type="stmt" count="0"/>
<line num="123" type="stmt" count="0"/>
<line num="124" type="stmt" count="0"/>
<line num="126" type="stmt" count="0"/>
<line num="127" type="stmt" count="0"/>
<line num="128" type="stmt" count="0"/>
<line num="129" type="stmt" count="0"/>
<line num="131" type="stmt" count="0"/>
<line num="133" type="stmt" count="0"/>
<line num="135" type="stmt" count="0"/>
<line num="136" type="stmt" count="0"/>
<line num="138" type="stmt" count="0"/>
<line num="139" type="stmt" count="0"/>
<line num="140" type="stmt" count="0"/>
<line num="142" type="stmt" count="0"/>
<line num="143" type="stmt" count="0"/>
<line num="145" type="stmt" count="0"/>
<line num="146" type="stmt" count="0"/>
<line num="148" type="stmt" count="0"/>
<line num="154" type="method" name="complex" crap="132" count="0"/>
<line num="156" type="stmt" count="0"/>
<line num="157" type="stmt" count="0"/>
<line num="158" type="stmt" count="0"/>
<line num="159" type="stmt" count="0"/>
<line num="160" type="stmt" count="0"/>
<line num="162" type="stmt" count="0"/>
<line num="163" type="stmt" count="0"/>
<line num="164" type="stmt" count="0"/>
<line num="165" type="stmt" count="0"/>
<line num="167" type="stmt" count="0"/>
<line num="169" type="stmt" count="0"/>
<line num="171" type="stmt" count="0"/>
<line num="172" type="stmt" count="0"/>
<line num="174" type="stmt" count="0"/>
<line num="175" type="stmt" count="0"/>
<line num="176" type="stmt" count="0"/>
<line num="178" type="stmt" count="0"/>
<line num="179" type="stmt" count="0"/>
<line num="181" type="stmt" count="0"/>
<line num="182" type="stmt" count="0"/>
<line num="184" type="stmt" count="0"/>
<line num="185" type="stmt" count="0"/>
<line num="186" type="stmt" count="0"/>
<line num="187" type="stmt" count="0"/>
<line num="188" type="stmt" count="0"/>
<line num="190" type="stmt" count="0"/>
<line num="191" type="stmt" count="0"/>
<line num="192" type="stmt" count="0"/>
<line num="193" type="stmt" count="0"/>
<line num="195" type="stmt" count="0"/>
<line num="197" type="stmt" count="0"/>
<line num="199" type="stmt" count="0"/>
<line num="200" type="stmt" count="0"/>
<line num="202" type="stmt" count="0"/>
<line num="203" type="stmt" count="0"/>
<line num="204" type="stmt" count="0"/>
<line num="206" type="stmt" count="0"/>
<line num="207" type="stmt" count="0"/>
<line num="209" type="stmt" count="0"/>
<line num="210" type="stmt" count="0"/>
<line num="212" type="stmt" count="0"/>
<metrics loc="214" ncloc="140" classes="1" methods="4" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="85" coveredstatements="2" elements="89" coveredelements="4"/>
</file>
<metrics files="1" loc="214" ncloc="140" classes="1" methods="4" coveredmethods="2" conditionals="0" coveredconditionals="0" statements="85" coveredstatements="2" elements="89" coveredelements="4"/>
</project>
</coverage>

+ 52
- 0
it/it-projects/plugins/project/target/php/phpunit.xml View File

@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="Test Suite" tests="12" assertions="11" failures="7" errors="0" time="8.036518">
<testsuite name="PhpUnderControl_Example_MathTest" file="tests/SomeTest.php" fullPackage="Example" package="Example" tests="12" assertions="11" failures="7" errors="0" time="8.036518">
<testcase name="testAddSuccess" class="PhpUnderControl_Example_MathTest" file="tests/SomeTest.php" line="72" assertions="1" time="2.006604"/>
<testcase name="testSubSuccess" class="PhpUnderControl_Example_MathTest" file="tests/SomeTest.php" line="81" assertions="1" time="0.000842"/>
<testcase name="testSubFail" class="PhpUnderControl_Example_MathTest" file="tests/SomeTest.php" line="89" assertions="1" time="2.006533">
<failure type="PHPUnit_Framework_ExpectationFailedException">PhpUnderControl_Example_MathTest::testSubFail
Failed asserting that 1 matches expected 0.
</failure>
</testcase>
<testsuite name="PhpUnderControl_Example_MathTest::testDataProviderOneWillFail" tests="4" assertions="4" failures="1" errors="0" time="4.008126">
<testcase name="testDataProviderOneWillFail with data set #0" assertions="1" time="1.001100"/>
<testcase name="testDataProviderOneWillFail with data set #1" assertions="1" time="1.001209"/>
<testcase name="testDataProviderOneWillFail with data set #2" assertions="1" time="1.004137">
<failure type="PHPUnit_Framework_ExpectationFailedException">PhpUnderControl_Example_MathTest::testDataProviderOneWillFail with data set #2 (7, 1)
Failed asserting that 6 matches expected 1.
</failure>
</testcase>
<testcase name="testDataProviderOneWillFail with data set #3" assertions="1" time="1.001680"/>
</testsuite>
<testsuite name="PhpUnderControl_Example_MathTest::testDataProviderAllWillFail" tests="4" assertions="4" failures="4" errors="0" time="0.012665">
<testcase name="testDataProviderAllWillFail with data set #0" assertions="1" time="0.003173">
<failure type="PHPUnit_Framework_ExpectationFailedException">PhpUnderControl_Example_MathTest::testDataProviderAllWillFail with data set #0 (17, 42)
Failed asserting that -25 matches expected 1.

</failure>
</testcase>
<testcase name="testDataProviderAllWillFail with data set #1" assertions="1" time="0.003231">
<failure type="PHPUnit_Framework_ExpectationFailedException">PhpUnderControl_Example_MathTest::testDataProviderAllWillFail with data set #1 (13, 23)
Failed asserting that -10 matches expected 1.
</failure>
</testcase>
<testcase name="testDataProviderAllWillFail with data set #2" assertions="1" time="0.003100">
<failure type="PHPUnit_Framework_ExpectationFailedException">PhpUnderControl_Example_MathTest::testDataProviderAllWillFail with data set #2 (42, 17)
Failed asserting that 25 matches expected 1.
</failure>
</testcase>
<testcase name="testDataProviderAllWillFail with data set #3" assertions="1" time="0.003161">
<failure type="PHPUnit_Framework_ExpectationFailedException">PhpUnderControl_Example_MathTest::testDataProviderAllWillFail with data set #3 (23, 13)
Failed asserting that 10 matches expected 1.
</failure>
</testcase>
</testsuite>
<testcase name="testFail" class="PhpUnderControl_Example_MathTest" file="tests/SomeTest.php" line="119" assertions="0" time="0.001748">
<failure type="PHPUnit_Framework_AssertionFailedError">PhpUnderControl_Example_MathTest::testFail
Failed because...
</failure>
</testcase>
</testsuite>
</testsuite>
</testsuites>

+ 66
- 0
it/it-projects/plugins/project/target/surefire-reports/TEST-foo.FooTest.xml View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="0" time="0.004" errors="0" skipped="0" tests="1" name="foo.FooTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib"/>
<property name="java.vm.version" value="24.71-b01"/>
<property name="user.country.format" value="FR"/>
<property name="gopherProxySet" value="false"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="java.vendor.url" value="http://java.oracle.com/"/>
<property name="path.separator" value=":"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
<property name="file.encoding.pkg" value="sun.io"/>
<property name="user.country" value="US"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="sun.os.patch.level" value="unknown"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="/Users/sbrandhof/dev/core/sonar-tests-core/platform/projects/all-langs"/>
<property name="java.runtime.version" value="1.7.0_71-b14"/>
<property name="java.awt.graphicsenv" value="sun.awt.CGraphicsEnvironment"/>
<property name="java.endorsed.dirs" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/endorsed"/>
<property name="os.arch" value="x86_64"/>
<property name="java.io.tmpdir" value="/var/folders/ny/2lkywbzs63xc1n1k7rzprjj40000gn/T/"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="os.name" value="Mac OS X"/>
<property name="classworlds.conf" value="/usr/local/Cellar/maven32/3.2.5/libexec/bin/m2.conf"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.library.path" value="/Users/sbrandhof/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.class.version" value="51.0"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="os.version" value="10.10.3"/>
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="user.home" value="/Users/sbrandhof"/>
<property name="user.timezone" value="Europe/Paris"/>
<property name="java.awt.printerjob" value="sun.lwawt.macosx.CPrinterJob"/>
<property name="java.specification.version" value="1.7"/>
<property name="file.encoding" value="UTF-8"/>
<property name="user.name" value="sbrandhof"/>
<property name="java.class.path" value="/usr/local/Cellar/maven32/3.2.5/libexec/boot/plexus-classworlds-2.5.2.jar"/>
<property name="java.vm.specification.version" value="1.7"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.home" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre"/>
<property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher package"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="user.language" value="en"/>
<property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/>
<property name="java.vm.info" value="mixed mode"/>
<property name="java.version" value="1.7.0_71"/>
<property name="java.ext.dirs" value="/Users/sbrandhof/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"/>
<property name="sun.boot.class.path" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/classes"/>
<property name="java.vendor" value="Oracle Corporation"/>
<property name="maven.home" value="/usr/local/Cellar/maven32/3.2.5/libexec"/>
<property name="file.separator" value="/"/>
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.io.unicode.encoding" value="UnicodeBig"/>
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="sun.cpu.isalist" value=""/>
</properties>
<testcase time="0.004" classname="foo.FooTest" name="testAdd"/>
</testsuite>

+ 66
- 0
it/it-projects/plugins/project/target/surefire-reports/TEST-foo.SimplestTest.xml View File

@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite failures="0" time="0" errors="0" skipped="0" tests="1" name="foo.SimplestTest">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib"/>
<property name="java.vm.version" value="24.71-b01"/>
<property name="user.country.format" value="FR"/>
<property name="gopherProxySet" value="false"/>
<property name="java.vm.vendor" value="Oracle Corporation"/>
<property name="java.vendor.url" value="http://java.oracle.com/"/>
<property name="path.separator" value=":"/>
<property name="guice.disable.misplaced.annotation.check" value="true"/>
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
<property name="file.encoding.pkg" value="sun.io"/>
<property name="user.country" value="US"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="sun.os.patch.level" value="unknown"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="/Users/sbrandhof/dev/core/sonar-tests-core/platform/projects/all-langs"/>
<property name="java.runtime.version" value="1.7.0_71-b14"/>
<property name="java.awt.graphicsenv" value="sun.awt.CGraphicsEnvironment"/>
<property name="java.endorsed.dirs" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/endorsed"/>
<property name="os.arch" value="x86_64"/>
<property name="java.io.tmpdir" value="/var/folders/ny/2lkywbzs63xc1n1k7rzprjj40000gn/T/"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
<property name="os.name" value="Mac OS X"/>
<property name="classworlds.conf" value="/usr/local/Cellar/maven32/3.2.5/libexec/bin/m2.conf"/>
<property name="sun.jnu.encoding" value="UTF-8"/>
<property name="java.library.path" value="/Users/sbrandhof/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:."/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.class.version" value="51.0"/>
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
<property name="os.version" value="10.10.3"/>
<property name="http.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="user.home" value="/Users/sbrandhof"/>
<property name="user.timezone" value="Europe/Paris"/>
<property name="java.awt.printerjob" value="sun.lwawt.macosx.CPrinterJob"/>
<property name="java.specification.version" value="1.7"/>
<property name="file.encoding" value="UTF-8"/>
<property name="user.name" value="sbrandhof"/>
<property name="java.class.path" value="/usr/local/Cellar/maven32/3.2.5/libexec/boot/plexus-classworlds-2.5.2.jar"/>
<property name="java.vm.specification.version" value="1.7"/>
<property name="sun.arch.data.model" value="64"/>
<property name="java.home" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre"/>
<property name="sun.java.command" value="org.codehaus.plexus.classworlds.launcher.Launcher package"/>
<property name="java.specification.vendor" value="Oracle Corporation"/>
<property name="user.language" value="en"/>
<property name="awt.toolkit" value="sun.lwawt.macosx.LWCToolkit"/>
<property name="java.vm.info" value="mixed mode"/>
<property name="java.version" value="1.7.0_71"/>
<property name="java.ext.dirs" value="/Users/sbrandhof/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java"/>
<property name="sun.boot.class.path" value="/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/resources.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/rt.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/sunrsasign.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jsse.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jce.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/jfr.jar:/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/classes"/>
<property name="java.vendor" value="Oracle Corporation"/>
<property name="maven.home" value="/usr/local/Cellar/maven32/3.2.5/libexec"/>
<property name="file.separator" value="/"/>
<property name="java.vendor.url.bug" value="http://bugreport.sun.com/bugreport/"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.io.unicode.encoding" value="UnicodeBig"/>
<property name="socksNonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="ftp.nonProxyHosts" value="local|*.local|169.254/16|*.169.254/16"/>
<property name="sun.cpu.isalist" value=""/>
</properties>
<testcase time="0" classname="foo.SimplestTest" name="testAdd"/>
</testsuite>

+ 4
- 0
it/it-projects/plugins/project/target/surefire-reports/foo.FooTest.txt View File

@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: foo.FooTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 sec

+ 4
- 0
it/it-projects/plugins/project/target/surefire-reports/foo.SimplestTest.txt View File

@@ -0,0 +1,4 @@
-------------------------------------------------------------------------------
Test set: foo.SimplestTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 sec

BIN
it/it-projects/plugins/project/target/test-classes/foo/FooTest.class View File


BIN
it/it-projects/plugins/project/target/test-classes/foo/SimplestTest.class View File


+ 12
- 0
it/it-projects/plugins/project/test/java/foo/FooTest.java View File

@@ -0,0 +1,12 @@
package foo;

import org.junit.Test;
import static org.junit.Assert.*;

public class FooTest {

@Test
public void testAdd() throws Exception {
assertEquals(Foo.div(10, 5), 2);
}
}

+ 12
- 0
it/it-projects/plugins/project/test/java/foo/SimplestTest.java View File

@@ -0,0 +1,12 @@
package foo;

import org.junit.Test;
import static org.junit.Assert.*;

public class SimplestTest {

@Test
public void testAdd() throws Exception {
assertEquals(Simplest.add(4, 5), 9);
}
}

+ 13
- 0
it/it-projects/plugins/project/test/js/PersonTest.js View File

@@ -0,0 +1,13 @@
TestCase('PersonTest', {

testWhoAreYou : function() {
var p = new Person('John', 'Doe', 'P.');
assertEquals('Should have responded with full name', 'John P. Doe', p.whoAreYou());
},

testWhoAreYouWithNoMiddleName : function() {
var p = new Person('John', 'Doe');
assertEquals('Should have used only first and last name', 'John Doe', p.whoAreYou());
}

});

+ 18
- 0
it/it-projects/plugins/project/test/js/com/company/CarTest.js View File

@@ -0,0 +1,18 @@
TestCase('com.company.CarTest', {

testfullName : function() {
var car = new Car('VW', 'Beatle', 1971);
assertEquals('VW Beatle Y: 1971', car.getFullName());
},

testStopEngineWithCheck : function() {
var car = new Car('VW', 'Beatle', 1971);
assertEquals('engine was not running', car.stopEngineWithCheck());
},

testCalculatePrice : function() {
var car = new Car('Volvo', 'XC70', 2012);
assertEquals('$30000', car.calculatePrice());
}

});

+ 169
- 0
it/it-projects/plugins/project/test/php/SomeTest.php View File

@@ -0,0 +1,169 @@
<?php
/**
* This file is part of phpUnderControl.
*
* Copyright (c) 2007-2009, Manuel Pichler <mapi@phpundercontrol.org>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Manuel Pichler nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

require_once dirname(__FILE__) . '/../../src/php/Math.php';

/**
* Simple math test class.
*
* @package Example
* @author Manuel Pichler <mapi@phpundercontrol.org>
* @copyright 2007-2009 Manuel Pichler. All rights reserved.
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @version Release: 0.5.0
* @link http://www.phpundercontrol.org/
*/
class PhpUnderControl_Example_MathTest extends PHPUnit_Framework_TestCase
{
/**
* The used math object.
*
* @var PhpUnderControl_Example_Math $math
*/
protected $math = null;

/**
* Creates a new {@link PhpUnderControl_Example_Math} object.
*/
public function setUp()
{
parent::setUp();

$this->math = new PhpUnderControl_Example_Math();
}

/**
* Successful test.
*/
public function testAddSuccess()
{
sleep(2);
$this->assertEquals(4, $this->math->add(1, 3));
}

/**
* Successful test.
*/
public function testSubSuccess()
{
$this->assertEquals( -2, $this->math->sub( 1, 3 ) );
}
/**
* Failing test.
*/
public function testSubFail()
{
sleep(2);
$this->assertEquals( 0, $this->math->sub( 2, 1 ) );
}
/**
* Test case with data provider.
*
* @dataProvider dataProviderOne
*/
public function testDataProviderOneWillFail( $x, $y )
{
sleep(1);
$this->assertEquals( 1, $this->math->sub( $x, $y ) );
}
/**
* Test case with data provider.
*
* @dataProvider dataProviderTwo
*/
public function testDataProviderAllWillFail( $x, $y )
{
$this->assertEquals( 1, $this->math->sub( $x, $y ) );
}
/**
* Failing test.
*/
public function testFail()
{
$this->fail('Failed because...');
}
/**
* Skipping test.
*/
public function testMarkSkip()
{
$this->markTestSkipped('Skipped because...');
}
/**
* Skipping test.
*/
public function testMarkIncomplete()
{
$this->markTestIncomplete('Incomplete because...');
}
/**
* Example data provider.
*
* @return array(array)
*/
public static function dataProviderOne()
{
return array(
array( 2, 1 ),
array( 3, 2 ),
array( 7, 1 ),
array( 9, 8 ),
);
}
/**
* Example data provider.
*
* @return array(array)
*/
public static function dataProviderTwo()
{
return array(
array( 17, 42 ),
array( 13, 23 ),
array( 42, 17 ),
array( 23, 13 ),
);
}
}

+ 8
- 6
it/it-tests/pom.xml View File

@@ -18,6 +18,13 @@
</properties>

<dependencies>
<!-- must be declared first -->
<dependency>
<groupId>com.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId>
<version>3.3-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.sonar.plugins</groupId>
<artifactId>sonar-xoo-plugin</artifactId>
@@ -40,18 +47,13 @@
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>15.0</version>
<version>18.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-ws-client</artifactId>
<version>5.0</version>
</dependency>
<dependency>
<groupId>com.sonarsource.orchestrator</groupId>
<artifactId>sonar-orchestrator</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-update-center-common</artifactId>

+ 138
- 0
it/it-tests/src/test/java/plugins/PluginsTest.java View File

@@ -0,0 +1,138 @@
/*
* Copyright (C) 2009-2014 SonarSource SA
* All rights reserved
* mailto:contact AT sonarsource DOT com
*/
package plugins;

import com.google.common.base.Joiner;
import com.google.common.collect.Sets;
import com.sonar.orchestrator.Orchestrator;
import com.sonar.orchestrator.OrchestratorBuilder;
import com.sonar.orchestrator.build.SonarRunner;
import plugins.checks.AbapCheck;
import plugins.checks.CCheck;
import plugins.checks.Check;
import plugins.checks.CobolCheck;
import plugins.checks.CppCheck;
import plugins.checks.CssCheck;
import plugins.checks.FlexCheck;
import plugins.checks.GroovyCheck;
import plugins.checks.JavaCheck;
import plugins.checks.JavascriptCheck;
import plugins.checks.PhpCheck;
import plugins.checks.PythonCheck;
import plugins.checks.RpgCheck;
import plugins.checks.SwiftCheck;
import plugins.checks.Validation;
import plugins.checks.WebCheck;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ErrorCollector;
import org.sonar.updatecenter.common.Plugin;
import org.sonar.updatecenter.common.Release;

/**
* Verify that the plugins available in update center
* are correctly supported.
*/
public class PluginsTest {

/**
* Temporarily disabled plugins. To be re-enabled.
*/
static final Set<String> DISABLED_PLUGINS = Sets.newHashSet("devcockpit", "views", /* FIXME */"vb");

/**
* See http://license.internal.sonarsource.com/it/
*/
static final Set<String> LICENSED_PLUGINS = Sets.newHashSet(
"abap", "cobol", "cpp", "devcockpit", "objc", "pli", "plsql", "report", "rpg",
"sqale", "swift", "vb", "vbnet", "views");

static final Set<String> DISABLED_PLUGINS_FOR_PREVIEW_MODE = Sets.newHashSet("mantis",

// Caused by: Access to the secured property 'sonar.scm.user.secured' is not possible in preview mode. The SonarQube plugin which requires
// this property must be deactivated in preview mode.
"scmstats");

// TODO new PliCheck() is temporarily disabled as PLI plugin does not support multi-language feature. See sonar-project.properties
static final List<Check> CHECKS = Arrays.asList((Check) new AbapCheck(), new CobolCheck(), new CCheck(), new CppCheck(), new CssCheck(),
new FlexCheck(), new GroovyCheck(), new JavaCheck(), new JavascriptCheck(), new PhpCheck(), new RpgCheck(),
new PythonCheck(), new SwiftCheck(), /* FIXME new VbCheck(),*/ new WebCheck()
);

static Orchestrator orchestrator;

@BeforeClass
public static void startServer() {
OrchestratorBuilder builder = Orchestrator.builderEnv();

// install latest compatible releases of plugins
org.sonar.updatecenter.common.Version sonarVersion = org.sonar.updatecenter.common.Version.create(builder.getSonarVersion());
builder.getUpdateCenter().setInstalledSonarVersion(sonarVersion);
for (Plugin plugin : builder.getUpdateCenter().findAllCompatiblePlugins()) {
if (!DISABLED_PLUGINS.contains(plugin.getKey())) {
Release release = plugin.getLastCompatibleRelease(sonarVersion);
if (release != null) {
builder.setOrchestratorProperty(plugin.getKey() + "Version", release.getVersion().toString());
builder.addPlugin(plugin.getKey());
}
}
}
activateLicenses(builder);
orchestrator = builder.build();
orchestrator.start();
}

@Rule
public ErrorCollector errorCollector = new ErrorCollector();

@Test
public void analysis_of_project_with_all_supported_languages() {
SonarRunner analysis = newAnalysis();
orchestrator.executeBuild(analysis);
for (Check check : CHECKS) {
System.out.println(check.getClass().getSimpleName() + "...");
check.validate(new Validation(orchestrator, errorCollector));
}
}

@Test
public void preview_analysis_of_project_with_all_supported_languages() {
SonarRunner analysis = newAnalysis();
analysis.setProperty("sonar.analysis.mode", "preview");
String excludedPlugins = Joiner.on(",").join(DISABLED_PLUGINS_FOR_PREVIEW_MODE);
if (orchestrator.getServer().version().toString().startsWith("5.1.1")) {
// This bug was fixed in SQ 5.2:
// Caused by: java.lang.UnsupportedOperationException: Unable to find rule by query
// at org.sonar.batch.rule.RuleFinderCompatibility.find(RuleFinderCompatibility.java:57)
// at org.sonar.plugins.groovy.codenarc.CodeNarcSensor.parse(CodeNarcSensor.java:118)
excludedPlugins += ",groovy";

// http://jira.sonarsource.com/browse/SONAR-6673 fixed in 5.1.2
excludedPlugins += ",issueassign";
}
analysis.setProperty("sonar.preview.excludePlugins", excludedPlugins);
orchestrator.executeBuild(analysis);
}

private SonarRunner newAnalysis() {
SonarRunner analysis = SonarRunner.create(Project.basedir());
analysis.setEnvironmentVariable("SONAR_RUNNER_OPTS", "-XX:MaxPermSize=128m");
return analysis;
}

private static void activateLicenses(OrchestratorBuilder builder) {
for (String licensedPlugin : LICENSED_PLUGINS) {
if (!DISABLED_PLUGINS.contains(licensedPlugin)) {
builder.activateLicense(licensedPlugin);
}
}
}

}

+ 31
- 0
it/it-tests/src/test/java/plugins/Project.java View File

@@ -0,0 +1,31 @@
package plugins;

import com.google.common.base.Function;
import java.io.File;
import java.util.Collection;
import javax.annotation.Nullable;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import util.ItUtils;

import static com.google.common.collect.FluentIterable.from;

public class Project {

public static File basedir() {
return ItUtils.projectDir("plugins/project");
}

public static Iterable<String> allFilesInDir(final String dirPath) {
Collection<File> files = FileUtils.listFiles(new File(basedir(), dirPath), null, true);
return from(files).transform(new Function<File, String>() {
@Nullable
public String apply(File file) {
// transforms /absolute/path/to/src/java/Foo.java to src/java/Foo.java
String filePath = FilenameUtils.separatorsToUnix(file.getPath());
return dirPath + StringUtils.substringAfterLast(filePath, dirPath);
}
});
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/AbapCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class AbapCheck implements Check {

public static final String DIR = "src/abap";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/CCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class CCheck implements Check {

public static final String DIR = "src/c";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 5
- 0
it/it-tests/src/test/java/plugins/checks/Check.java View File

@@ -0,0 +1,5 @@
package plugins.checks;

public interface Check {
void validate(Validation validation);
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/CobolCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class CobolCheck implements Check {

public static final String DIR = "src/cobol";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/CppCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class CppCheck implements Check {

public static final String DIR = "src/cpp";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 14
- 0
it/it-tests/src/test/java/plugins/checks/CssCheck.java View File

@@ -0,0 +1,14 @@
package plugins.checks;

public class CssCheck implements Check {

public static final String DIR = "src/css";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/FlexCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class FlexCheck implements Check {

public static final String DIR = "src/flex";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
validation.mustHaveIssues(DIR + "/HasIssues.as");
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/GroovyCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class GroovyCheck implements Check {

public static final String DIR = "src/groovy";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/JavaCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class JavaCheck implements Check {

public static final String DIR = "src/java";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 16
- 0
it/it-tests/src/test/java/plugins/checks/JavascriptCheck.java View File

@@ -0,0 +1,16 @@
package plugins.checks;

public class JavascriptCheck implements Check {

public static final String SRC_DIR = "src/js";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(SRC_DIR);
validation.mustHaveSize(SRC_DIR);
validation.mustHaveComments(SRC_DIR);
validation.mustHaveComplexity(SRC_DIR);
validation.mustHaveIssues(SRC_DIR + "/HasIssues.js");
validation.mustHaveMeasuresGreaterThan(SRC_DIR + "/Person.js", 0, "coverage");
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/PhpCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class PhpCheck implements Check {

public static final String DIR = "src/php";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/PliCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class PliCheck implements Check {

public static final String DIR = "src/pli";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
validation.mustHaveIssues(DIR + "/hasissues.pli");
}
}

+ 27
- 0
it/it-tests/src/test/java/plugins/checks/PythonCheck.java View File

@@ -0,0 +1,27 @@
package plugins.checks;

import plugins.Project;

public class PythonCheck implements Check {

public static final String DIR = "src/python";

@Override
public void validate(Validation validation) {
// all files have size measures, even empty __init__.py
validation.mustHaveSize(DIR);

for (String filePath : Project.allFilesInDir(DIR)) {
if (filePath.endsWith("__init__.py")) {
validation.mustHaveSource(filePath);
} else {
validation.mustHaveNonEmptySource(filePath);
validation.mustHaveComments(filePath);
validation.mustHaveComplexity(filePath);
}
}

validation.mustHaveIssues(DIR + "/hasissues.py");
}

}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/RpgCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class RpgCheck implements Check {

public static final String DIR = "src/rpg";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 14
- 0
it/it-tests/src/test/java/plugins/checks/SwiftCheck.java View File

@@ -0,0 +1,14 @@
package plugins.checks;

public class SwiftCheck implements Check {

public static final String DIR = "src/swift";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 114
- 0
it/it-tests/src/test/java/plugins/checks/Validation.java View File

@@ -0,0 +1,114 @@
package plugins.checks;

import com.google.common.base.Joiner;
import com.sonar.orchestrator.Orchestrator;
import plugins.Project;
import java.io.File;
import org.hamcrest.Matchers;
import org.junit.rules.ErrorCollector;
import org.sonar.wsclient.services.Measure;
import org.sonar.wsclient.services.Resource;
import org.sonar.wsclient.services.ResourceQuery;
import org.sonar.wsclient.services.Source;
import org.sonar.wsclient.services.SourceQuery;

import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.notNullValue;

/**
*
* TODO must have syntax highlighting
* TODO must have duplications
* TODO must have issues with SQALE characteristic and debt
* TODO must have rules with characteristic
* TODO must have tests
* TODO must have coverage
*/
public class Validation {

private final Orchestrator orchestrator;
private final ErrorCollector errorCollector;

public Validation(Orchestrator orchestrator, ErrorCollector errorCollector) {
this.orchestrator = orchestrator;
this.errorCollector = errorCollector;
}

public void mustHaveIssues(String path) {
// TODO use the WS api/issues
mustHaveMeasuresGreaterThan(path, 1, "violations");
}

public void mustHaveComments(String path) {
mustHaveMeasuresGreaterThan(path, 0, "comment_lines", "comment_lines_density");
}

public void mustHaveComplexity(String path) {
mustHaveMeasuresGreaterThan(path, 0, "complexity");
}

public void mustHaveSize(String path) {
mustHaveMeasuresGreaterThan(path, 0, "ncloc", "lines");
}

public void mustHaveMeasuresGreaterThan(String path, int min, String... metricKeys) {
for (String filePath : toFiles(path)) {
fileMustHaveMeasures(filePath, metricKeys, min);
}
}

private void fileMustHaveMeasures(String filePath, String[] metricKeys, int min) {
Resource resource = getMeasureForComponentKey(filePathToKey(filePath), metricKeys);
errorCollector.checkThat("Measures " + Joiner.on(",").join(metricKeys) + " are set on file " + filePath, resource, notNullValue());
if (resource != null) {
for (String metricKey : metricKeys) {
Measure measure = resource.getMeasure(metricKey);
errorCollector.checkThat("Measure " + metricKey + " is set on file " + filePath, measure, notNullValue());
if (measure != null && measure.getIntValue() != null) {
errorCollector.checkThat("Measure " + metricKey + " is positive on file " + filePath, measure.getIntValue(), Matchers.greaterThanOrEqualTo(min));
}
}
}
}

/**
* Checks that each source file of the given directory is uploaded to server.
* @param path relative path to source directory or source file
*/
public void mustHaveNonEmptySource(String path) {
mustHaveSourceWithAtLeast(path, 1);
}

public void mustHaveSource(String path) {
mustHaveSourceWithAtLeast(path, 0);
}

private void mustHaveSourceWithAtLeast(String path, int minLines) {
for (String filePath : toFiles(path)) {
Source source = orchestrator.getServer().getWsClient().find(SourceQuery.create(filePathToKey(filePath)));
errorCollector.checkThat("Source is set on file " + filePath, source, notNullValue());
if (source != null) {
errorCollector.checkThat("Source is not empty on file " + filePath, source.getLines().size(), Matchers.greaterThanOrEqualTo(minLines));
}
}
}

private Iterable<String> toFiles(String path) {
File fileOrDir = new File(Project.basedir(), path);
if (!fileOrDir.exists()) {
throw new IllegalArgumentException("Path does not exist: " + fileOrDir);
}
if (fileOrDir.isDirectory()) {
return Project.allFilesInDir(path);
}
return asList(path);
}

public Resource getMeasureForComponentKey(String resourceKey, String... metricKeys) {
return orchestrator.getServer().getWsClient().find(ResourceQuery.createForMetrics(resourceKey, metricKeys));
}

private String filePathToKey(String filePath) {
return "all-langs:" + filePath;
}
}

+ 15
- 0
it/it-tests/src/test/java/plugins/checks/VbCheck.java View File

@@ -0,0 +1,15 @@
package plugins.checks;

public class VbCheck implements Check {

public static final String DIR = "src/vb";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
validation.mustHaveComplexity(DIR);
}
}

+ 14
- 0
it/it-tests/src/test/java/plugins/checks/WebCheck.java View File

@@ -0,0 +1,14 @@
package plugins.checks;

public class WebCheck implements Check {

public static final String DIR = "src/web";

@Override
public void validate(Validation validation) {
validation.mustHaveNonEmptySource(DIR);
validation.mustHaveIssues(DIR);
validation.mustHaveSize(DIR);
validation.mustHaveComments(DIR);
}
}

+ 0
- 0
it/it-tests/src/test/resources/logback-test.xml View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save