├── .gitignore ├── .gitlab-ci.yml ├── .travis.yml ├── COPYING.GPLv3 ├── LICENSE ├── Makefile ├── README.md ├── appveyor-install.ps1 ├── appveyor-opam.sh ├── appveyor.yml ├── autoconf ├── .gitignore ├── Makefile.config.in ├── Makefile.rules ├── aclocal.m4 ├── build.ocp ├── config.ocp2gen.in ├── config.ocpgen.in ├── configure ├── configure.ac ├── generated.files ├── m4 │ ├── ax_compare_version.m4 │ └── ocaml.m4 ├── ocaml-config.h.in ├── travis-ci.sh └── travis-install.sh ├── build.ocp ├── config.ocp.in ├── configure ├── libs ├── ocplib-ace │ ├── .depend │ ├── ace.ml │ ├── ace.mli │ ├── ace_types.mli │ └── build.ocp ├── ocplib-compiler │ ├── build.ocp │ ├── lexer_iter.ml │ ├── lexer_iter.mli │ ├── parsetree_iter.ml │ ├── parsetree_iter.mli │ ├── parsetree_map.ml │ ├── parsetree_map.mli │ ├── typedtree_iter.ml │ ├── typedtree_iter.mli │ ├── typedtree_map.ml │ └── typedtree_map.mli ├── ocplib-d3pie │ ├── .depend │ ├── build.ocp │ ├── d3.js │ ├── d3.map │ ├── d3pie.ml │ ├── d3pie.mli │ └── d3pie_types.mli ├── ocplib-gettext │ ├── build.ocp │ ├── ocpGettext.ml │ └── ocpGettext.mli ├── ocplib-jsutils │ ├── .depend │ ├── build.ocp │ ├── js_utils.ml │ └── js_utils.mli ├── ocplib-ppx │ ├── build.ocp │ ├── ppx_mapper.ml │ └── ppx_mapper.mli └── ocplib-sempatch │ ├── .gitignore │ ├── .gitlab-ci.yml │ ├── README.md │ ├── build.ocp │ └── lib │ ├── ast_element.ml │ ├── automaton │ ├── automaton.ml │ ├── eval.ml │ ├── eval.mli │ └── generator │ │ ├── abc.ml │ │ ├── abc.mli │ │ ├── automaton_processor.ml │ │ ├── automaton_processor.mli │ │ ├── common.ml │ │ ├── common.mli │ │ ├── eval_builder.ml │ │ ├── eval_builder.mli │ │ ├── from.ml │ │ ├── from.mli │ │ ├── generic.ml │ │ ├── match_builder.ml │ │ ├── match_builder.mli │ │ ├── spec.org │ │ ├── tree402.mli │ │ ├── tree403.mli │ │ ├── tree404.mli │ │ ├── tree405.mli │ │ ├── tree406.mli │ │ ├── type_collector.ml │ │ ├── type_collector.mli │ │ ├── wildcard.ml │ │ └── wildcard.mli │ ├── failure.ml │ ├── failure.mli │ ├── guard_evaluator.ml │ ├── guard_evaluator.mli │ ├── match.ml │ ├── match.mli │ ├── parsing │ ├── code_lexer.mll │ ├── code_parser.mly │ ├── guard.ml │ ├── guard.mli │ ├── guard_lexer.mll │ ├── guard_parser.mly │ ├── parsed_patches.ml │ ├── parsed_patches.mli │ ├── patch_lexer.mll │ ├── patch_parser.mly │ ├── raw_patch.ml │ └── raw_patch.mli │ ├── sempatch.ml │ ├── sempatch.mli │ ├── std_utils.ml │ ├── std_utils │ ├── sUError.ml │ ├── sUError.mli │ ├── sUFun.ml │ ├── sUFun.mli │ ├── sUList.ml │ ├── sUList.mli │ ├── sUMessages.ml │ ├── sUMessages.mli │ ├── sUMisc.ml │ ├── sUMisc.mli │ ├── sUOption.ml │ ├── sUOption.mli │ ├── sUStringMap.ml │ ├── sUStringMap.mli │ └── std_utils.ml │ ├── substitution.ml │ └── substitution.mli ├── ocp-autoconf.config ├── opam ├── plugins ├── README.txt ├── make_db_test.sh ├── ocp-lint-plugin-complex │ ├── build.ocp │ ├── interface_module_type_name.ml │ ├── plugin_complex.ml │ └── tests │ │ ├── .ocplint │ │ ├── build.ocp │ │ └── module_type_name │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ ├── 2d1e84397f8aec6661adbf688ce7b73a │ │ └── 33145cbee016a553d5385ef2bf540c54 │ │ ├── test_module_type_name.ml │ │ └── test_module_type_name.mli ├── ocp-lint-plugin-files │ ├── build.ocp │ ├── interface_missing.ml │ ├── plugin_file_system.ml │ ├── project_files.ml │ └── tests │ │ ├── .ocplint │ │ ├── build.ocp │ │ └── interface_missing │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ └── 06e08076b07bd84b1d19c9c5f869ca4d │ │ └── test_interface_missing.ml ├── ocp-lint-plugin-indent │ ├── build.ocp │ ├── ocp_indent.ml │ ├── plugin_indent.ml │ └── tests │ │ ├── .ocplint │ │ ├── build.ocp │ │ └── ocp_indent │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ ├── 4d4b5217df862462ae39042a1dade445 │ │ ├── 566910322489a75fde76df5112fe7999 │ │ ├── 9f85cae42d6265c02d4cdbbe80cc0ee1 │ │ └── cf5282d2ebef628872c880f0730e92aa │ │ └── test_ocp_indent.ml ├── ocp-lint-plugin-parsetree │ ├── build.ocp │ ├── checkClass.ml │ ├── checkConstructorArgs.ml │ ├── checkExternal.ml │ ├── checkGoodPractices.ml │ ├── checkPatternGuard.ml │ ├── checkPolymorphicVariants.ml │ ├── checkTypeDeclaration.ml │ ├── identifier_length.ml │ ├── list_function_on_singleton.ml │ ├── physical_comp_on_alloc_lit.ml │ ├── plugin_parsetree.ml │ ├── redefine_std_lib.ml │ ├── std_lib.ml │ └── tests │ │ ├── .ocplint │ │ ├── build.ocp │ │ ├── identifier_length │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 7d7e4e04dacf6d2b16f9bc90ebf9c802 │ │ └── test_identifier_length.ml │ │ ├── list_fun_on_singleton │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 6dea8cfb1a7de94d5f362d6548c55948 │ │ └── test_list_fun_on_singleton.ml │ │ ├── physical_comp_on_allocated_lit │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 83f1ad17f3d27d1004a7ce287bce32a3 │ │ └── test_phys_comp_on_allocated_lit.ml │ │ └── redefine_std_lib │ │ ├── .ocplint │ │ ├── config.ml │ │ ├── ocp-lint.result │ │ ├── 8c794107745dd52f38ec72d064978d6a │ │ └── f87a9ba7d82e0113f012a8b023b1efce │ │ └── test_redefine_std_lib.ml ├── ocp-lint-plugin-parsing │ ├── .gitignore │ ├── apply-patch.sh │ ├── build.ocp │ ├── gen-patch.sh │ ├── lintParsingGetFeatures.ml │ ├── lintParsingLinter.ml │ ├── lintParsingLinterCheckTuple.ml │ ├── lintParsingPlugin.ml │ ├── lintParsing_Ast_helper.ml │ ├── lintParsing_Ast_iterator.ml │ ├── lintParsing_Ast_iterator.mli │ ├── lintParsing_Asttypes.mli │ ├── lintParsing_Docstrings.ml │ ├── lintParsing_Lexer.mll │ ├── lintParsing_Location.ml │ ├── lintParsing_Parse.ml │ ├── lintParsing_Parse.mli │ ├── lintParsing_Parser.mly │ ├── lintParsing_Parsetree.mli │ ├── lintParsing_Syntaxerr.ml │ ├── main.ml │ └── tests │ │ ├── .gitignore │ │ ├── .ocplint │ │ ├── .ocpstop │ │ ├── Makefile │ │ ├── build.ocp │ │ ├── test.ml │ │ └── test.reference ├── ocp-lint-plugin-sempatch │ ├── build.ocp │ ├── lint_sempatch.ml │ ├── patches │ │ └── core_patch.md │ ├── plugin_patch.ml │ └── tests │ │ ├── .ocplint │ │ ├── build.ocp │ │ ├── sempatch_backward_if │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── d08e9b505b422eb779cb21717ed422d1 │ │ └── test_sempatch_backward_if.ml │ │ ├── sempatch_comp_to_false │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 3be2d8938459aa4ecf1ca7f35d8ea31d │ │ └── test_sempatch_comp_to_false.ml │ │ ├── sempatch_comp_to_true │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 866b4dd68fbcbb7c7ad4ab4b2fd11503 │ │ └── test_sempatch_comp_to_true.ml │ │ ├── sempatch_constant_if │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 75784dd883a4fe0bcc3293e8b54c4d93 │ │ └── test_constant_if.ml │ │ ├── sempatch_empty_list_compare │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── be780e4c73479987acccf2bc0487e652 │ │ └── test_sempatch_empty_list_cmp.ml │ │ ├── sempatch_identity_let │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 897663146003983141984362715f3b92 │ │ └── test_identity_let.ml │ │ ├── sempatch_incr_decr │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── b413206f36fadacad9a83e5cdcd1caba │ │ └── test_sempatch_incr_decr.ml │ │ ├── sempatch_parallel_let_bindings │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 4444496085a17b45c9007c6fc3d24f19 │ │ ├── sempatch.md │ │ └── test_parallel_let_bindings.ml │ │ ├── sempatch_succ_pred │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 1f3f548f2e69a9d5a787221b9aa2cf80 │ │ ├── sempatch.md │ │ └── test_sempatch_succ_pred.ml │ │ ├── sempatch_test_list_op_on_lit │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── b1e981b56e350a82c813f0beba0db8b9 │ │ └── test_sempatch_list_op_on_lit.ml │ │ ├── sempatch_traverse_nodes │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 65ff12f9029c7c14b4928167bfde08ea │ │ ├── sempatch.md │ │ └── test_sempatch_traverse_nodes.ml │ │ ├── sempatch_useless_else │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ │ └── 66ca2da272df0568b40e918f2f0dfac9 │ │ └── test_sempatch_useless_else.ml │ │ └── sempatch_useless_if │ │ ├── .ocplint │ │ ├── ocp-lint.result │ │ └── 1b78a7f1828148dd946df9b5fcaaf4ac │ │ └── test_sempatch_useless_if.ml ├── ocp-lint-plugin-text │ ├── build.ocp │ ├── code_length.ml │ ├── not_that_char.ml │ ├── plugin_text.ml │ ├── tests │ │ ├── .ocplint │ │ ├── build.ocp │ │ └── code_length │ │ │ ├── .ocplint │ │ │ ├── ocp-lint.result │ │ │ └── 21a080aedc1da1f0a11c1121fdec16b6 │ │ │ └── test_code_length.ml │ └── useless_space.ml ├── ocp-lint-plugin-tokens │ ├── build.ocp │ ├── checkTokens.ml │ └── plugin_tokens.ml └── ocp-lint-plugin-typedtree │ ├── build.ocp │ ├── checkFullyQualified.ml │ ├── checkHashtbl.ml │ ├── checkIdentifier.ml │ ├── checkIdentifierMasking.ml │ ├── checkInheritance.ml │ ├── checkModuleUtilization.ml │ ├── plugin_typedtree.ml │ ├── polymorphic_comparison.ml │ └── tests │ ├── .gitignore │ ├── .ocplint │ ├── .ocpstop │ ├── Makefile │ ├── build.ocp │ ├── test.ml │ └── test.reference ├── push-opam.sh ├── scripts └── pre-commit-lint ├── specs ├── Makefile ├── biblio.bib ├── conclusion.tex ├── config-build-install.tex ├── configuration.tex ├── database.tex ├── extensibility.tex ├── overview.tex ├── related.tex ├── sempatch.tex ├── sempatch_example.sp ├── typerex-lint.pdf ├── typerex-lint.tex ├── usage.tex └── use-cases.tex ├── testsuite ├── .ocplint ├── README.md ├── build.ocp └── testsuite.ml └── tools ├── ocp-lint-doc ├── README.md ├── build.ocp ├── css │ ├── bootstrap.css │ ├── bootstrap.min.css │ ├── ocplint.css │ ├── searchicon.png │ └── simple-sidebar.css ├── examples │ ├── plugin_complex.interface_module_type_name.1.ml │ ├── plugin_complex.interface_module_type_name.1.warn │ ├── plugin_file_system.interface_missing.1.ml │ ├── plugin_file_system.interface_missing.1.warn │ ├── plugin_file_system.project_files.1.ml │ ├── plugin_file_system.project_files.1.warn │ ├── plugin_file_system.project_files.2.ml │ ├── plugin_file_system.project_files.2.warn │ ├── plugin_indent.ocp_indent.1.ml │ ├── plugin_indent.ocp_indent.1.warn │ ├── plugin_parsetree.check_constr_args.1.ml │ ├── plugin_parsetree.check_constr_args.1.warn │ ├── plugin_parsetree.code_identifier_length.1.ml │ ├── plugin_parsetree.code_identifier_length.1.warn │ ├── plugin_parsetree.code_identifier_length.2.ml │ ├── plugin_parsetree.code_identifier_length.2.warn │ ├── plugin_parsetree.code_list_on_singleton.1.ml │ ├── plugin_parsetree.code_list_on_singleton.1.warn │ ├── plugin_parsetree.code_list_on_singleton.2.ml │ ├── plugin_parsetree.code_list_on_singleton.2.warn │ ├── plugin_parsetree.code_redefine_stdlib_module.1.ml │ ├── plugin_parsetree.code_redefine_stdlib_module.1.warn │ ├── plugin_parsetree.code_redefine_stdlib_module.2.ml │ ├── plugin_parsetree.code_redefine_stdlib_module.2.warn │ ├── plugin_parsetree.external_code.1.ml │ ├── plugin_parsetree.external_code.1.warn │ ├── plugin_parsetree.fabrice_good_practices.1.ml │ ├── plugin_parsetree.fabrice_good_practices.1.warn │ ├── plugin_parsetree.fabrice_good_practices.2.ml │ ├── plugin_parsetree.fabrice_good_practices.2.warn │ ├── plugin_parsetree.pattern_guard.1.ml │ ├── plugin_parsetree.pattern_guard.1.warn │ ├── plugin_parsetree.phys_comp_allocated_lit.1.ml │ ├── plugin_parsetree.phys_comp_allocated_lit.1.warn │ ├── plugin_parsetree.polymorphic_variants.1.ml │ ├── plugin_parsetree.polymorphic_variants.1.warn │ ├── plugin_parsetree.type_declaration.1.ml │ ├── plugin_parsetree.type_declaration.1.warn │ ├── plugin_parsing.check_tuple.1.ml │ ├── plugin_parsing.check_tuple.1.warn │ ├── plugin_parsing.raw_syntax.1.ml │ ├── plugin_parsing.raw_syntax.1.warn │ ├── plugin_parsing.raw_syntax.2.ml │ ├── plugin_parsing.raw_syntax.2.warn │ ├── plugin_parsing.raw_syntax.3.ml │ ├── plugin_parsing.raw_syntax.3.warn │ ├── plugin_parsing.raw_syntax.4.ml │ ├── plugin_parsing.raw_syntax.4.warn │ ├── plugin_parsing.raw_syntax.5.ml │ ├── plugin_parsing.raw_syntax.5.warn │ ├── plugin_parsing.raw_syntax.6.ml │ ├── plugin_parsing.raw_syntax.6.warn │ ├── plugin_parsing.raw_syntax.7.ml │ ├── plugin_parsing.raw_syntax.7.warn │ ├── plugin_parsing.raw_syntax.8.ml │ ├── plugin_parsing.raw_syntax.8.warn │ ├── plugin_text.code_length.1.ml │ ├── plugin_text.code_length.1.warn │ ├── plugin_text.not_that_char.1.ml │ ├── plugin_text.not_that_char.1.warn │ ├── plugin_text.not_that_char.2.ml │ ├── plugin_text.not_that_char.2.warn │ ├── plugin_text.useless_space_line.1.ml │ ├── plugin_text.useless_space_line.1.warn │ ├── plugin_text.useless_space_line.2.ml │ ├── plugin_text.useless_space_line.2.warn │ ├── plugin_typedtree.check_hash_table.1.ml │ ├── plugin_typedtree.check_hash_table.1.warn │ ├── plugin_typedtree.check_identifier.1.ml │ ├── plugin_typedtree.check_identifier.1.warn │ ├── plugin_typedtree.check_identifier.2.ml │ ├── plugin_typedtree.check_identifier.2.warn │ ├── plugin_typedtree.check_identifier.3.ml │ ├── plugin_typedtree.check_identifier.3.warn │ ├── plugin_typedtree.check_identifier.4.ml │ ├── plugin_typedtree.check_identifier.4.warn │ ├── plugin_typedtree.fully_qualified_identifiers.1.ml │ ├── plugin_typedtree.fully_qualified_identifiers.1.warn │ ├── plugin_typedtree.module_utilization.1.ml │ ├── plugin_typedtree.module_utilization.1.warn │ ├── plugin_typedtree.module_utilization.2.ml │ ├── plugin_typedtree.module_utilization.2.warn │ ├── plugin_typedtree.module_utilization.3.ml │ ├── plugin_typedtree.module_utilization.3.warn │ ├── plugin_typedtree.polymorphic_function.1.ml │ └── plugin_typedtree.polymorphic_function.1.warn ├── js │ └── make_doc.js ├── make_doc.ml └── ocp.stop ├── ocp-lint-web ├── doc │ ├── img │ │ ├── ocp_lint_web_errors.png │ │ ├── ocp_lint_web_file.png │ │ ├── ocp_lint_web_file_errors.png │ │ ├── ocp_lint_web_file_warnings.png │ │ ├── ocp_lint_web_home.png │ │ └── ocp_lint_web_warnings.png │ ├── makefile │ └── ocp-lint-web.tex ├── src │ ├── build.ocp │ ├── web_code_viewer.ml │ ├── web_components.ml │ ├── web_components.mli │ ├── web_errors.ml │ ├── web_errors.mli │ ├── web_errors_content.ml │ ├── web_errors_content.mli │ ├── web_file_content.ml │ ├── web_file_content.mli │ ├── web_file_content_data.ml │ ├── web_file_content_data.mli │ ├── web_filter_system.ml │ ├── web_filter_system.mli │ ├── web_home_content.ml │ ├── web_home_content.mli │ ├── web_main.ml │ ├── web_navigation_system.ml │ ├── web_navigation_system.mli │ ├── web_utils.ml │ ├── web_utils.mli │ ├── web_warnings_content.ml │ └── web_warnings_content.mli └── static │ ├── css │ ├── adjustment_ace.css │ ├── adjustment_bootstrap.css │ ├── bootstrap.min.css │ ├── bootstrap.min.css.map │ └── ocp_lint_web.css │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ └── js │ ├── ace.js │ ├── bootstrap.min.js │ ├── d3.js │ ├── d3pie.min.js │ ├── jquery.min.js │ ├── mode-ocaml.js │ ├── ocaml_highlight_rules.js │ ├── ocplib_re.js │ ├── ocplib_unix.js │ └── theme-monokai.js └── ocp-lint ├── README.txt ├── api ├── build.ocp ├── lint_input.ml ├── lint_input.mli ├── lint_map.ml ├── lint_map.mli ├── lint_plugin.ml ├── lint_plugin.mli ├── lint_plugin_api.ml ├── lint_plugin_api.mli ├── lint_plugin_error.ml ├── lint_plugin_error.mli ├── lint_plugin_types.ml ├── lint_plugin_types.mli ├── lint_types.ml ├── lint_types.mli ├── lint_warning.ml ├── lint_warning.mli ├── lint_warning_decl.ml ├── lint_warning_decl.mli ├── lint_warning_types.ml └── lint_warning_types.mli ├── config ├── build.ocp ├── lint_config.ml ├── lint_config.mli ├── lint_config_types.ml └── lint_config_types.mli ├── db ├── build.ocp ├── lint_db.ml ├── lint_db.mli ├── lint_db_error.ml ├── lint_db_error.mli ├── lint_db_types.ml └── lint_db_types.mli ├── init ├── build.ocp ├── lint_globals.ml └── lint_globals.mli ├── main ├── .ocplint ├── build.ocp ├── lint.ml ├── lint.mli ├── lint_actions.ml ├── lint_actions.mli ├── lint_init_dynload.ml ├── lint_init_dynload.mli ├── lint_parallel_engine.ml ├── lint_parallel_engine.mli └── main.ml ├── output ├── build.ocp ├── lint_text.ml ├── lint_text.mli ├── lint_web.ml ├── lint_web.mli ├── lint_web_analysis_info.ml └── lint_web_analysis_info.mli └── utils ├── build.ocp ├── lint_parse_args.ml ├── lint_parse_args.mli ├── lint_utils.ml └── lint_utils.mli /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | _obuild 3 | *.err 4 | *.out 5 | *.output 6 | _olint 7 | /tools/ocp-lint-web/static/js/ocp_lint_web.js 8 | /tools/ocp-lint-web/static/js/ocp_lint_web_codeviewer.js 9 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | cache: 2 | paths: 3 | - .opam 4 | 5 | build: 6 | tags: 7 | - jessie 8 | - amd64 9 | - opam 10 | script: 11 | - eval $(opam config env) 12 | - export OPAMROOT=${PWD}/.opam 13 | - | 14 | if [ ! -d ${OPAMROOT} ]; then 15 | opam init default /var/cache/opam-repository 16 | fi 17 | - opam switch 4.02.3 18 | - eval $(opam config env) 19 | - opam install ocp-build menhir yojson 20 | - ./configure 21 | - make 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | sudo: false 3 | addons: 4 | apt: 5 | sources: 6 | - avsm 7 | packages: 8 | - ocaml 9 | - opam 10 | - ocaml-native-compilers 11 | install: sh -ex ./autoconf/travis-install.sh 12 | cache: 13 | directories: 14 | - ${HOME}/.opam 15 | script: sh -ex ./autoconf/travis-ci.sh 16 | env: 17 | - OCAML_VERSION=system 18 | - OCAML_VERSION=4.02.3 19 | - OCAML_VERSION=4.03.0 20 | - OCAML_VERSION=4.04.0 21 | - OCAML_VERSION=4.05.0 22 | - OCAML_VERSION=4.06.0 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # rule: do not use @ to hide commands 3 | # 4 | 5 | #generated by ./configure 6 | include autoconf/Makefile.config 7 | 8 | OPAMDEPS=yojson menhir ocp-indent ocp-build ppx_tools \ 9 | js_of_ocaml-tyxml js_of_ocaml-camlp4 omd lwt 10 | 11 | OCPBUILD=ocp-build 12 | OCAMLOPT=ocamlopt.opt 13 | OCAMLC=ocamlc 14 | SRC=src 15 | 16 | all: 17 | if [ ! -d "_obuild" ]; then $(OCPBUILD) init; fi 18 | $(OCPBUILD) 19 | 20 | test: 21 | $(OCPBUILD) tests 22 | 23 | clean: 24 | $(OCPBUILD) clean 25 | 26 | cleanall: distclean 27 | 28 | distclean: ocp-distclean 29 | 30 | opam-deps: 31 | opam install $(OPAMDEPS) 32 | 33 | install: 34 | $(OCPBUILD) install \ 35 | --install-lib $(ocamldir) --install-meta $(metadir) \ 36 | --install-bin $(bindir) 37 | 38 | uninstall: 39 | $(OCPBUILD) install --uninstall-only 40 | 41 | include autoconf/Makefile.rules 42 | 43 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | platform: 2 | - x86 3 | 4 | environment: 5 | FORK_USER: ocaml 6 | FORK_BRANCH: master 7 | CYG_ROOT: C:\cygwin64 8 | 9 | install: 10 | - ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/$env:FORK_USER/ocaml-ci-scripts/$env:FORK_BRANCH/appveyor-install.ps1")) 11 | 12 | build_script: 13 | - call %CYG_ROOT%\bin\bash.exe -l %APPVEYOR_BUILD_FOLDER%\appveyor-opam.sh 14 | -------------------------------------------------------------------------------- /autoconf/.gitignore: -------------------------------------------------------------------------------- 1 | /config.ocpgen 2 | /config.ocp2gen 3 | /Makefile.config 4 | /autom4te.cache 5 | /config.status 6 | /config.log 7 | /ocaml-config.h 8 | -------------------------------------------------------------------------------- /autoconf/Makefile.config.in: -------------------------------------------------------------------------------- 1 | OCAMLFIND=@OCAMLFIND@ 2 | CONFIGURE_ARGS=@CONFIGURE_ARGS@ 3 | ROOTDIR=@ROOTDIR@ 4 | prefix=@prefix@ 5 | exec_prefix=@exec_prefix@ 6 | bindir=@bindir@ 7 | libdir=@libdir@ 8 | datarootdir=@datarootdir@ 9 | mandir=@mandir@ 10 | datadir=@datadir@ 11 | ocamldir=@ocamldir@ 12 | metadir=@metadir@ 13 | PACKAGE_NAME=@PACKAGE_NAME@ 14 | PACKAGE_VERSION=@PACKAGE_VERSION@ 15 | OPAM_REPO=@OPAM_REPO@ 16 | OPAM_REPO_OFFICIAL_REMOTE=@OPAM_REPO_OFFICIAL_REMOTE@ 17 | OPAM_REPO_FORK_REMOTE=@OPAM_REPO_FORK_REMOTE@ 18 | DOWNLOAD_URL_PREFIX=@DOWNLOAD_URL_PREFIX@ 19 | OCAMLVERSION=@OCAMLVERSION@ 20 | OCAMLC=@OCAMLC@ 21 | OCAMLOPT=@OCAMLOPT@ 22 | OCAMLDEP=@OCAMLDEP@ 23 | OCAMLMKTOP=@OCAMLMKTOP@ 24 | OCAMLMKLIB=@OCAMLMKLIB@ 25 | OCAMLDOC=@OCAMLDOC@ 26 | OCAMLLIB=@OCAMLLIB@ 27 | OCAMLBIN=@OCAMLBIN@ 28 | OCAML_USE_BINANNOT=@OCAML_USE_BINANNOT@ 29 | -------------------------------------------------------------------------------- /autoconf/Makefile.rules: -------------------------------------------------------------------------------- 1 | 2 | autoconf/Makefile.config: autoconf/configure 3 | ./configure $(CONFIGURE_ARGS) 4 | 5 | 6 | # We can override this variable to change the binary to use 7 | # for ocp-build 8 | ifeq ($(OCP_BUILD),) 9 | OCP_BUILD:=ocp-build 10 | endif 11 | 12 | _obuild: Makefile 13 | $(OCP_BUILD) init 14 | 15 | ocp-build-build: _obuild 16 | $(OCP_BUILD) 17 | 18 | ocp-build-install: _obuild 19 | $(OCP_BUILD) install \ 20 | -install-bin $(bindir) \ 21 | -install-lib $(ocamldir) \ 22 | -install-meta $(metadir) 23 | 24 | ocp-build-clean: _obuild 25 | $(OCP_BUILD) clean 26 | 27 | ocp-build-distclean: 28 | rm -rf _obuild 29 | 30 | ocp-lint-distclean: 31 | rm -rf _olint 32 | 33 | ocp-autoconf-distclean: 34 | rm -f autoconf/Makefile.config 35 | rm -f autoconf/config.ocpgen 36 | rm -f autoconf/config.ocp2gen 37 | rm -f autoconf/config.status 38 | rm -f autoconf/config.log 39 | rm -f autoconf/ocaml-config.h 40 | rm -rf autoconf/autom4te.cache/ 41 | 42 | ocp-distclean: ocp-autoconf-distclean ocp-build-distclean ocp-lint-distclean 43 | -------------------------------------------------------------------------------- /autoconf/aclocal.m4: -------------------------------------------------------------------------------- 1 | # generated automatically by aclocal 1.15 -*- Autoconf -*- 2 | 3 | # Copyright (C) 1996-2014 Free Software Foundation, Inc. 4 | 5 | # This file is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 11 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 12 | # PARTICULAR PURPOSE. 13 | 14 | m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) 15 | m4_include([m4/ax_compare_version.m4]) 16 | m4_include([m4/ocaml.m4]) 17 | -------------------------------------------------------------------------------- /autoconf/build.ocp: -------------------------------------------------------------------------------- 1 | (* Just here to refer to this directory *) 2 | if include "config.ocpgen" then {} else {} 3 | begin library autoconf_dir end 4 | -------------------------------------------------------------------------------- /autoconf/config.ocp2gen.in: -------------------------------------------------------------------------------- 1 | autoconf = { 2 | conf_ocamlfind="@OCAMLFIND@"; 3 | rootdir="@ROOTDIR@"; 4 | prefix="@prefix@"; 5 | exec_prefix="@exec_prefix@"; 6 | bindir="@bindir@"; 7 | libdir="@libdir@"; 8 | datarootdir="@datarootdir@"; 9 | mandir="@mandir@"; 10 | datadir="@datadir@"; 11 | ocamldir="@ocamldir@"; 12 | metadir="@metadir@"; 13 | package_name="@PACKAGE_NAME@"; 14 | package_version="@PACKAGE_VERSION@"; 15 | opam_repo="@OPAM_REPO@"; 16 | opam_repo_official_remote="@OPAM_REPO_OFFICIAL_REMOTE@"; 17 | opam_repo_fork_remote="@OPAM_REPO_FORK_REMOTE@"; 18 | download_url_prefix="@DOWNLOAD_URL_PREFIX@"; 19 | conf_ocamlversion="@OCAMLVERSION@"; 20 | conf_ocamlc="@OCAMLC@"; 21 | conf_ocamlopt="@OCAMLOPT@"; 22 | conf_ocamldep="@OCAMLDEP@"; 23 | conf_ocamlmktop="@OCAMLMKTOP@"; 24 | conf_ocamlmklib="@OCAMLMKLIB@"; 25 | conf_ocamldoc="@OCAMLDOC@"; 26 | conf_ocamllib="@OCAMLLIB@"; 27 | conf_ocamlbin="@OCAMLBIN@"; 28 | ocaml_use_binannot = @OCAML_USE_BINANNOT@; 29 | autoconf_dir = "@PACKAGE_NAME@-autoconf-dir"; 30 | 31 | }; (* end of "autoconf = {" *) 32 | 33 | ocaml.exists = true; 34 | ocaml = { bytecomp = []; asmcomp = [] } + ocaml; 35 | 36 | if( autoconf.ocaml_use_binannot && ocaml_version >= "4.00" ) { 37 | ocaml.bytecomp += [ "-bin-annot" ]; 38 | ocaml.asmcomp += [ "-bin-annot" ]; 39 | } 40 | 41 | autoconf_cflags = [ "-I"; "autoconf" ]; 42 | 43 | if( ocaml_version = "4.01.0+ocp1" || ocaml_version = "4.02.1+ocp1" ) { 44 | string_compat = []; 45 | ocp_pp = []; 46 | } else { 47 | string_compat = [ "ocplib-compat" ]; 48 | ocp_pp = [ "ocp-pp" ]; 49 | } 50 | 51 | if( ocaml_version < "4.01" ){ 52 | compiler_libs_compat = [ "compiler-libs.compat" ]; 53 | } else { 54 | compiler_libs_compat = []; 55 | } 56 | -------------------------------------------------------------------------------- /autoconf/config.ocpgen.in: -------------------------------------------------------------------------------- 1 | conf_ocamlfind="@OCAMLFIND@" 2 | rootdir="@ROOTDIR@" 3 | prefix="@prefix@" 4 | exec_prefix="@exec_prefix@" 5 | bindir="@bindir@" 6 | libdir="@libdir@" 7 | datarootdir="@datarootdir@" 8 | mandir="@mandir@" 9 | datadir="@datadir@" 10 | ocamldir="@ocamldir@" 11 | metadir="@metadir@" 12 | package_name="@PACKAGE_NAME@" 13 | package_version="@PACKAGE_VERSION@" 14 | opam_repo="@OPAM_REPO@" 15 | opam_repo_official_remote="@OPAM_REPO_OFFICIAL_REMOTE@" 16 | opam_repo_fork_remote="@OPAM_REPO_FORK_REMOTE@" 17 | download_url_prefix="@DOWNLOAD_URL_PREFIX@" 18 | conf_ocamlversion="@OCAMLVERSION@" 19 | conf_ocamlc="@OCAMLC@" 20 | conf_ocamlopt="@OCAMLOPT@" 21 | conf_ocamldep="@OCAMLDEP@" 22 | conf_ocamlmktop="@OCAMLMKTOP@" 23 | conf_ocamlmklib="@OCAMLMKLIB@" 24 | conf_ocamldoc="@OCAMLDOC@" 25 | conf_ocamllib="@OCAMLLIB@" 26 | conf_ocamlbin="@OCAMLBIN@" 27 | ocaml_use_binannot = @OCAML_USE_BINANNOT@ 28 | autoconf_dir = "@PACKAGE_NAME@-autoconf-dir" 29 | 30 | 31 | if ocaml_use_bin_annot && ocaml_version >= "4.00" then { 32 | comp += [ "-bin-annot" ] 33 | } 34 | 35 | autoconf_cflags = [ "-I" "autoconf" ] 36 | 37 | if ocaml_version = "4.01.0+ocp1" || ocaml_version = "4.02.1+ocp1" then { 38 | string_compat = []; 39 | ocp_pp = []; 40 | } else { 41 | string_compat = [ "ocplib-compat" ] 42 | ocp_pp = [ "ocp-pp" ]; 43 | } 44 | 45 | if ocaml_version < "4.01" then { 46 | compiler_libs_compat = [ "compiler-libs.compat" ] 47 | } else { 48 | compiler_libs_compat = [] 49 | } 50 | -------------------------------------------------------------------------------- /autoconf/generated.files: -------------------------------------------------------------------------------- 1 | .travis.yml 7fbb6cdb9bc853ff6dcdc2ce8af57206 2 | autoconf/.gitignore 00973f185af428536c3caff11a53626d 3 | autoconf/Makefile.config.in 8edc4964d3e8d09eb9867cadc98d13a7 4 | autoconf/Makefile.rules c9e85dee44380b1a855cb2d49da44d54 5 | autoconf/build.ocp 9d81103f0dd977b6414645b9ab29c713 6 | autoconf/config.ocp2gen.in 98b5f8ae8a16187c0c76daccc72bee2d 7 | autoconf/config.ocpgen.in 159639bcf1a04a7c846aa1dffe556db9 8 | autoconf/configure.ac 591dcc6231e7dc08aeb91aa2e29a3a58 9 | autoconf/m4/ax_compare_version.m4 ebb455a7fd6a8ba9a4e38a25c8f0b686 10 | autoconf/m4/ocaml.m4 bffe7da970a9e23a89b611c00360f36f 11 | autoconf/ocaml-config.h.in 361f7d5a23b30c6c49756a9e34c2dcf9 12 | autoconf/travis-ci.sh e22cfae9156c383ce5a4abf646798a17 13 | autoconf/travis-install.sh 9bfd3722ac873da3f33d69fd670659b2 14 | ocp-autoconf.d/configure.ac bb8a88addef00eed10bfc70827998e9e 15 | opam a2c1b9114d4d81fa06544968c4e58902 16 | push-opam.sh c48fac7c8991f96357c9fc65a2ae6288 17 | -------------------------------------------------------------------------------- /autoconf/ocaml-config.h.in: -------------------------------------------------------------------------------- 1 | #@OCAML_USE_POSIX_TYPES@ OCAML_USE_POSIX_TYPES 2 | -------------------------------------------------------------------------------- /autoconf/travis-ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | export OPAMYES=1 OPAMVERBOSE=1 4 | eval `opam config env` 5 | 6 | echo Architecture 7 | uname -a 8 | echo OCaml version 9 | ocaml -version 10 | echo OPAM versions 11 | opam --version 12 | opam --git-version 13 | 14 | PREFIX=$HOME/.opam/$OCAML_VERSION 15 | 16 | opam pin add my-package . 17 | opam install my-package 18 | opam remove my-package 19 | 20 | -------------------------------------------------------------------------------- /autoconf/travis-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This is what we would do if we needed something more: 4 | export OPAMYES=1 OPAMVERBOSE=1 5 | 6 | echo System OCaml version 7 | ocaml -version 8 | echo OPAM versions 9 | opam --version 10 | opam --git-version 11 | 12 | opam init 13 | opam switch $OCAML_VERSION 14 | 15 | -------------------------------------------------------------------------------- /build.ocp: -------------------------------------------------------------------------------- 1 | 2 | if include "autoconf/config.ocpgen" then {} else {} 3 | 4 | optcomp_opt = %string(strings = [ 5 | "-let ocaml_full_version=(" 6 | ocaml_major_version "," 7 | ocaml_minor_version "," 8 | ocaml_point_version 9 | ")" 10 | ]) 11 | 12 | camlp4_optcomp_js = [ 13 | "camlp4o" 14 | (* "%{optcomp_SRC_DIR}%/optcomp.cma" optcomp_opt *) 15 | "%{js_of_ocaml-camlp4_SRC_DIR}%/pa_js.cma" 16 | ] 17 | 18 | camlp4_js = [ 19 | "camlp4o" 20 | "%{js_of_ocaml-camlp4_SRC_DIR}%/pa_js.cma" 21 | ] 22 | 23 | camlp4_optcomp = [ 24 | "camlp4o" 25 | (* "%{optcomp_SRC_DIR}%/optcomp.cma" optcomp_opt *) 26 | ] 27 | -------------------------------------------------------------------------------- /config.ocp.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/config.ocp.in -------------------------------------------------------------------------------- /configure: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd autoconf; ./configure $* 4 | cd .. 5 | echo Creating root directory _obuild/ 6 | mkdir -p _obuild 7 | rm -f boot/.ocpstop 8 | 9 | -------------------------------------------------------------------------------- /libs/ocplib-ace/.depend: -------------------------------------------------------------------------------- 1 | ace.cmo : ace_types.cmi ace.cmi 2 | ace.cmx : ace_types.cmi ace.cmi 3 | ocaml_mode.cmo : ../../src/jslib/js_utils.cmi ace_types.cmi ace.cmi \ 4 | ocaml_mode.cmi 5 | ocaml_mode.cmx : ../../src/jslib/js_utils.cmx ace_types.cmi ace.cmx \ 6 | ocaml_mode.cmi 7 | ace_types.cmi : 8 | ace.cmi : ace_types.cmi 9 | ocaml_mode.cmi : ace.cmi 10 | -------------------------------------------------------------------------------- /libs/ocplib-ace/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocplib-ace" 22 | link += [ "-linkall" ] 23 | files = [ 24 | "ace_types.mli" 25 | "ace.ml" ( pp = camlp4_optcomp_js ) 26 | ] 27 | requires = [ 28 | "ocplib-jsutils" 29 | "js_of_ocaml" 30 | "lwt" 31 | "ocp-indent.lib" 32 | ] 33 | end 34 | -------------------------------------------------------------------------------- /libs/ocplib-compiler/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocplib-compiler" 22 | files = [ 23 | "parsetree_iter.ml" 24 | "parsetree_map.ml" 25 | "typedtree_iter.ml" 26 | (* "typedtree_map.ml" TODO: cago does not compile *) 27 | "lexer_iter.ml" 28 | ] 29 | requires = [ "compiler-libs.common" ] 30 | pp = [ "ocp-pp" ] 31 | end 32 | -------------------------------------------------------------------------------- /libs/ocplib-compiler/lexer_iter.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | val iter_tokens : (Parser.token -> Location.t -> unit) -> string -> unit 22 | val get_tokens : string -> (Parser.token * Location.t) array 23 | -------------------------------------------------------------------------------- /libs/ocplib-compiler/typedtree_iter.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | module type IteratorArgument = TypedtreeIter.IteratorArgument 22 | 23 | module MakeIterator = TypedtreeIter.MakeIterator 24 | 25 | module DefaultIteratorArgument = TypedtreeIter.DefaultIteratorArgument 26 | 27 | val iter_structure : (module IteratorArgument) -> Cmt_format.cmt_infos -> unit 28 | val iter_signature : (module IteratorArgument) -> Cmt_format.cmt_infos -> unit 29 | -------------------------------------------------------------------------------- /libs/ocplib-d3pie/.depend: -------------------------------------------------------------------------------- 1 | xor.cmo : xor.cmi 2 | xor.cmx : xor.cmi 3 | js_utils.cmo : js_utils.cmi 4 | js_utils.cmx : js_utils.cmi 5 | lwt_request.cmo : js_utils.cmi lwt_request.cmi 6 | lwt_request.cmx : js_utils.cmx lwt_request.cmi 7 | xor_main.cmo : xor.cmi 8 | xor_main.cmx : xor.cmx 9 | xor.cmi : 10 | js_utils.cmi : 11 | lwt_request.cmi : 12 | -------------------------------------------------------------------------------- /libs/ocplib-gettext/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro TypeRex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the LGPL v2.1 with *) 7 | (* the special exception on linking described in the file LICENSE. *) 8 | (* (GNU Lesser General Public Licence version 2.1) *) 9 | (* *) 10 | (* Contact: (http://www.ocamlpro.com/) *) 11 | (* *) 12 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 13 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 14 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 15 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 16 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 17 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 18 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 19 | (* SOFTWARE. *) 20 | (**************************************************************************) 21 | 22 | 23 | 24 | begin library "ocplib-gettext" 25 | 26 | files = [ 27 | "ocpGettext.ml" (* translation files *) 28 | ] 29 | 30 | 31 | requires = [ 32 | "ocplib-config"; 33 | ] 34 | 35 | end 36 | -------------------------------------------------------------------------------- /libs/ocplib-jsutils/.depend: -------------------------------------------------------------------------------- 1 | xor.cmo : xor.cmi 2 | xor.cmx : xor.cmi 3 | js_utils.cmo : js_utils.cmi 4 | js_utils.cmx : js_utils.cmi 5 | lwt_request.cmo : js_utils.cmi lwt_request.cmi 6 | lwt_request.cmx : js_utils.cmx lwt_request.cmi 7 | xor_main.cmo : xor.cmi 8 | xor_main.cmx : xor.cmx 9 | xor.cmi : 10 | js_utils.cmi : 11 | lwt_request.cmi : 12 | -------------------------------------------------------------------------------- /libs/ocplib-jsutils/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocplib-jsutils" 22 | has_asm = false 23 | files = [ 24 | "js_utils.ml" ( pp = camlp4_optcomp_js ) 25 | ] 26 | requires = [ 27 | "js_of_ocaml" 28 | "js_of_ocaml.tyxml" 29 | ] 30 | end 31 | -------------------------------------------------------------------------------- /libs/ocplib-ppx/build.ocp: -------------------------------------------------------------------------------- 1 | 2 | begin library "ocplib-ppx"; 3 | 4 | files = [ "ppx_mapper.ml" ]; 5 | requires = [ "compiler-libs" ]; 6 | pp = [ "ocp-pp" ] 7 | end;; 8 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/ocaml 3 | 4 | ### OCaml ### 5 | *.annot 6 | *.cmo 7 | *.cma 8 | *.cmi 9 | *.a 10 | *.o 11 | *.cmx 12 | *.cmxs 13 | *.cmxa 14 | 15 | # ocamlbuild working directory 16 | _build/ 17 | 18 | # ocp-build working directory 19 | _obuild/ 20 | 21 | # ocamlbuild targets 22 | *.byte 23 | *.native 24 | 25 | # oasis generated files 26 | setup.data 27 | setup.log 28 | 29 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | cache: 2 | paths: 3 | - .opam 4 | 5 | build: 6 | tags: 7 | - jessie 8 | - amd64 9 | - opam 10 | script: 11 | - eval $(opam config env) 12 | - export OPAMROOT=${PWD}/.opam 13 | - | 14 | if [ ! -d ${OPAMROOT} ]; then 15 | opam init default /var/cache/opam-repository 16 | fi 17 | - eval $(opam config env) 18 | - opam install ocp-build menhir 19 | - ocp-build init 20 | - ocp-build tests 21 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/ast_element.ml: -------------------------------------------------------------------------------- 1 | type record_field = Longident.t Asttypes.loc * Parsetree.expression 2 | open Asttypes 3 | open Parsetree 4 | 5 | [%%create_ast_element] 6 | type t = Element.t 7 | let to_string = 8 | let open Pprintast in 9 | let to_string printer value = 10 | printer Format.str_formatter value; 11 | Format.flush_str_formatter () 12 | in 13 | function 14 | | Element.Expression e -> to_string expression e 15 | | Element.Pattern p -> to_string pattern p 16 | | _ -> "???" 17 | 18 | let from_structure e = Element.Structure e 19 | let from_expression e = Element.Expression e 20 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/eval.ml: -------------------------------------------------------------------------------- 1 | open Std_utils 2 | module A = Automaton.A 3 | module T = Ast_element.Element 4 | 5 | let semilazy_product_bind f l1 ll2 = match l1 with 6 | | [] -> [] 7 | | _ -> List.product_bind f l1 (Lazy.force ll2) 8 | 9 | 10 | let both 11 | = fun (s1, l1) (s2, l2) -> 12 | if not A.(s1.final && s2.final) then 13 | [] 14 | else 15 | let locations = 16 | List.sort_uniq compare 17 | [Match.get_location l1; Match.get_location l2] 18 | and merged_matches = { 19 | l2 with 20 | Match.substitutions = Substitution.merge 21 | (Match.get_substitutions l1) 22 | (Match.get_substitutions l2) 23 | ; 24 | } 25 | in 26 | match 27 | List.map ( 28 | fun loc -> Automaton.final (), 29 | { merged_matches with Match.location = loc } 30 | ) 31 | locations 32 | with 33 | | [] -> [Automaton.final (), merged_matches] 34 | | l -> l 35 | 36 | [%%create_eval] 37 | 38 | let apply name state elt = 39 | apply' 40 | (Match.mk name Substitution.empty None Location.none) 41 | state elt 42 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/eval.mli: -------------------------------------------------------------------------------- 1 | val apply : string -> Automaton.A.state -> Ast_element.t 2 | -> (Automaton.A.state * Match.t) list 3 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/abc.mli: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/libs/ocplib-sempatch/lib/automaton/generator/abc.mli -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/automaton_processor.mli: -------------------------------------------------------------------------------- 1 | val remove_arguments : Ast_mapper.mapper 2 | 3 | val convert_to_states : Ast_mapper.mapper 4 | 5 | val apply_to_tuples : Ast_mapper.mapper -> Ast_mapper.mapper 6 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/common.mli: -------------------------------------------------------------------------------- 1 | val id : string -> string 2 | val cstr : string -> string 3 | val print_longident : Longident.t -> string 4 | val upprint : Parsetree.core_type -> string option 5 | 6 | val mk_exploded : string -> Longident.t 7 | val mk_aut : string -> Longident.t 8 | val mk_aut_cstr : string -> Longident.t 9 | val mk_match : string -> Longident.t 10 | 11 | val warn : ('a, unit, string, unit) format4 -> 'a 12 | val debug : ('a, unit, string, unit) format4 -> 'a 13 | val raise_errorf : ?loc:Location.t -> ('a, unit, string, 'b) format4 -> 'a 14 | 15 | (** [instantiate_type_decl replacements typ] replaces all the free variables of 16 | typ present in the association list replacements by its corresponding value 17 | *) 18 | val instantiate_type_decl : (string * Parsetree.core_type) list 19 | -> Parsetree.type_declaration 20 | -> Parsetree.type_declaration 21 | 22 | (** Returns the list of toplevel value-bindings in the given structure *) 23 | val get_val_decls : Parsetree.structure -> Parsetree.value_binding list 24 | 25 | (** [filter_decls type_decls] returns the list of monomorphic type 26 | declarations in type_decls *) 27 | val filter_decls : Parsetree.type_declaration list 28 | -> Parsetree.type_declaration list 29 | 30 | val stdlib : Parsetree.type_declaration list 31 | val concrete_stdlib : Parsetree.type_declaration list 32 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/eval_builder.mli: -------------------------------------------------------------------------------- 1 | val combine_all : Parsetree.type_declaration list 2 | -> Parsetree.type_declaration list -> Parsetree.structure 3 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/from.mli: -------------------------------------------------------------------------------- 1 | include Generic.S with type t = Parsetree.structure 2 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/generic.ml: -------------------------------------------------------------------------------- 1 | open Std_utils 2 | open Asttypes 3 | open Parsetree 4 | 5 | module type ARG = 6 | sig 7 | type result 8 | type middle 9 | 10 | val deriver_name : string 11 | 12 | val middle_of_record : string 13 | -> Parsetree.label_declaration list 14 | -> middle list 15 | val middle_of_variant : string 16 | -> Parsetree.constructor_declaration list 17 | -> middle list 18 | val middle_of_alias : string 19 | -> (Parsetree.type_declaration -> middle list) 20 | -> Parsetree.type_declaration list 21 | -> Parsetree.core_type 22 | -> middle list 23 | 24 | val middle_of_abstract : string -> middle 25 | 26 | val result_of_middle : middle list -> result 27 | end 28 | 29 | module type S = 30 | sig 31 | type t 32 | 33 | val of_type_decl : env:Parsetree.type_declaration list 34 | -> Parsetree.type_declaration list 35 | -> t 36 | end 37 | 38 | module Make(Arg:ARG) : S with type t = Arg.result = 39 | struct 40 | type t = Arg.result 41 | 42 | let fail = Common.raise_errorf 43 | 44 | let of_type_decl ~env type_decls = 45 | let rec middle_creator type_decl = 46 | let loc = type_decl.ptype_loc in 47 | let name = type_decl.ptype_name.txt in 48 | Ast_helper.with_default_loc loc @@ fun () -> 49 | match type_decl.ptype_kind with 50 | | Ptype_variant cases -> 51 | Arg.middle_of_variant name cases 52 | | Ptype_record fields -> 53 | Arg.middle_of_record name fields 54 | | Ptype_abstract -> 55 | begin 56 | match type_decl.ptype_manifest with 57 | | Some typ -> 58 | Arg.middle_of_alias name middle_creator env typ 59 | | None -> [Arg.middle_of_abstract name] 60 | end 61 | | Ptype_open -> 62 | fail "%s can't handle abstract types" Arg.deriver_name 63 | in 64 | Arg.result_of_middle @@ List.bind middle_creator type_decls 65 | end 66 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/match_builder.mli: -------------------------------------------------------------------------------- 1 | include Generic.S with type t = Parsetree.structure 2 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/type_collector.ml: -------------------------------------------------------------------------------- 1 | open Parsetree 2 | module M = Ast_mapper 3 | module C = Common 4 | module H = Ast_helper 5 | 6 | (** Puts the list of all instanciated polymorphic types (and tuples) 7 | met in the [met_types] list ref, and returns the same tree with types 8 | replaced by their aliases *) 9 | let typ_collector met_types = 10 | let add_if_ok typ = 11 | match C.upprint typ with 12 | | Some name -> 13 | met_types := (C.id name, typ) :: !met_types; 14 | typ 15 | | None -> typ 16 | in 17 | { 18 | M.default_mapper with 19 | M.typ = (fun self typ -> 20 | let typ = M.(default_mapper.typ self typ) in 21 | match typ.ptyp_desc with 22 | | Ptyp_tuple _ 23 | | Ptyp_constr (_, _::_) -> 24 | add_if_ok typ 25 | | _ -> 26 | typ 27 | ); 28 | } 29 | 30 | (** [declare_core_typ name typ] creates a type declaration of the form [let 31 | name = typ] *) 32 | let declare_core_typ loc name typ = 33 | H.Type.mk 34 | ~manifest:typ 35 | (Location.mkloc name loc) 36 | 37 | (** [collect type_declarations] returns the list of type declarations 38 | [let id = typ] where typ is an instantiated constructor appearing in 39 | type_declarations (like [int list] of [string option], and id a unique 40 | identifier for the type *) 41 | let collect = function 42 | | [] -> [] 43 | | hd::_ as type_decls -> 44 | let loc = hd.ptype_loc in 45 | let types_list = ref [] in 46 | let collector = typ_collector types_list in 47 | let _ = List.map 48 | (collector.M.type_declaration collector) 49 | type_decls 50 | in 51 | List.sort_uniq (fun (id1, _) (id2, _) -> 52 | String.compare id1 id2 53 | ) 54 | !types_list 55 | |> List.map (fun (id, def) -> declare_core_typ loc id def) 56 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/type_collector.mli: -------------------------------------------------------------------------------- 1 | val typ_collector : (string * Parsetree.core_type) list ref -> Ast_mapper.mapper 2 | 3 | val collect : Parsetree.type_declaration list -> Parsetree.type_declaration list 4 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/automaton/generator/wildcard.mli: -------------------------------------------------------------------------------- 1 | include Generic.S with type t = Parsetree.structure 2 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/failure.ml: -------------------------------------------------------------------------------- 1 | type t = 2 | | Lexing of Lexing.position 3 | | Patch of string 4 | | Guard of string 5 | | Replacement of Location.t 6 | | Non_implemented of Location.t 7 | 8 | exception SempatchException of t 9 | 10 | let in_file_pos_to_string pos = 11 | Lexing.(Printf.sprintf "%d:%d" pos.pos_lnum (pos.pos_cnum - pos.pos_bol)) 12 | let position_to_string pos = 13 | Lexing.(Printf.sprintf 14 | "file %s at position %s" 15 | (if pos.pos_fname = "" then "NONE" else pos.pos_fname) 16 | (in_file_pos_to_string pos) 17 | ) 18 | 19 | let to_string = function 20 | | Lexing pos -> "Lexing error at " ^ (position_to_string pos) 21 | | Patch err -> "Parsing error : " ^ err 22 | | Non_implemented pos -> "Non implemented from " 23 | ^ (position_to_string pos.Location.loc_start) 24 | ^ "-" 25 | ^ (in_file_pos_to_string pos.Location.loc_end) 26 | | Guard err -> "Guard error : " ^ err 27 | | Replacement pos -> 28 | "Illegal use of the ast extension [@__sempatch_replace] at " 29 | ^ (position_to_string pos.Location.loc_start) 30 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/failure.mli: -------------------------------------------------------------------------------- 1 | type t = 2 | | Lexing of Lexing.position 3 | | Patch of string 4 | | Guard of string 5 | | Replacement of Location.t 6 | | Non_implemented of Location.t 7 | 8 | exception SempatchException of t 9 | 10 | val to_string : t -> string 11 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/guard_evaluator.mli: -------------------------------------------------------------------------------- 1 | val eval : Substitution.t -> Guard.t -> bool 2 | 3 | exception Undefined_var of string 4 | exception Undefined_function of string 5 | exception TypeError 6 | 7 | val eval_union : Substitution.t -> Guard.t list -> bool 8 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/match.ml: -------------------------------------------------------------------------------- 1 | type t = { 2 | patch_name : string; 3 | substitutions : Substitution.t; 4 | location : Location.t option; 5 | current_location : Location.t; 6 | } 7 | 8 | let get_patch_name t = (t.patch_name) 9 | let get_location t = t.location 10 | let get_current_location t = t.current_location 11 | let get_substitutions t = t.substitutions 12 | 13 | let set_patch_name x t = { t with patch_name = x } 14 | let set_location x t = { t with location = x } 15 | let set_current_location x t = { t with current_location = x } 16 | let set_substitutions x t = { t with substitutions = x } 17 | 18 | let mk name substitutions location current_location = { 19 | patch_name = name; 20 | substitutions; 21 | location; 22 | current_location; 23 | } 24 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/match.mli: -------------------------------------------------------------------------------- 1 | type t = { 2 | patch_name : string; 3 | substitutions : Substitution.t; 4 | location : Location.t option; 5 | current_location : Location.t; 6 | } 7 | 8 | val get_patch_name : t -> string 9 | val get_location : t -> Location.t option 10 | val get_current_location : t -> Location.t 11 | val get_substitutions : t -> Substitution.t 12 | 13 | val set_patch_name : string -> t -> t 14 | val set_location : Location.t option -> t -> t 15 | val set_current_location : Location.t -> t -> t 16 | val set_substitutions : Substitution.t -> t -> t 17 | 18 | val mk : string -> Substitution.t -> Location.t option -> Location.t -> t 19 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/code_lexer.mll: -------------------------------------------------------------------------------- 1 | { 2 | open Code_parser 3 | } 4 | 5 | 6 | let white = [' ' '\t']+ 7 | let newline = ('\r' | '\n' | "\r\n")+ 8 | let id = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_']* 9 | let ocaml_code = [^'+' '-' '\n'] [^'\n']* 10 | 11 | rule read_code = 12 | parse 13 | | "<..." newline { ENTER_SUBPATCH } 14 | | newline "...>" { EXIT_SUBPATCH } 15 | | newline* { EOL } 16 | | '+' { PLUS } 17 | | '-' { MINUS } 18 | | ocaml_code { CODE (Lexing.lexeme lexbuf) } 19 | | white { read_code lexbuf } 20 | | eof { EOF } 21 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/code_parser.mly: -------------------------------------------------------------------------------- 1 | %token EOF 2 | %token EOL 3 | %token ENTER_SUBPATCH 4 | %token EXIT_SUBPATCH 5 | %token PLUS 6 | %token MINUS 7 | %token CODE 8 | 9 | %start code 10 | %% 11 | 12 | code: 13 | | code = code_fragment EOF { code } 14 | 15 | code_fragment: 16 | | option(EOL) lines = separated_list (EOL, code_line) { lines } 17 | 18 | code_line: 19 | | code = CODE { Raw_patch.EQUAL code } 20 | | PLUS code = CODE { Raw_patch.ADD code } 21 | | MINUS code = CODE { Raw_patch.REMOVE code } 22 | | ENTER_SUBPATCH sub = code_fragment EXIT_SUBPATCH { Raw_patch.SUBPATCH sub } 23 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/guard.ml: -------------------------------------------------------------------------------- 1 | type t = 2 | | Variable of string 3 | | Litt_integer of int 4 | | Apply of string * t list 5 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/guard.mli: -------------------------------------------------------------------------------- 1 | type t = 2 | | Variable of string 3 | | Litt_integer of int 4 | | Apply of string * t list 5 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/guard_lexer.mll: -------------------------------------------------------------------------------- 1 | { 2 | module G = Guard 3 | open Guard_parser 4 | } 5 | 6 | let id = ['a'-'z' 'A'-'Z' '_'] ['a'-'z' 'A'-'Z' '0'-'9' '_']* 7 | let number = '-'? [ '0' - '9' ]* 8 | let infix_symbol = [ '=' '|' '&' ]* 9 | let open_paren = '(' 10 | let close_paren = ')' 11 | let comma = ',' 12 | let space = [ ' ' '\t' ] 13 | 14 | rule read = 15 | parse 16 | | space { read lexbuf } 17 | | id { ID (Lexing.lexeme lexbuf) } 18 | | number { NUMBER (int_of_string (Lexing.lexeme lexbuf)) } 19 | | infix_symbol { INFIX_OP (Lexing.lexeme lexbuf) } 20 | | open_paren { OPENING_PAREN } 21 | | close_paren { CLOSING_PAREN } 22 | | comma { COMMA } 23 | | eof { EOF } 24 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/guard_parser.mly: -------------------------------------------------------------------------------- 1 | %token ID 2 | %token INFIX_OP 3 | %token NUMBER 4 | %token OPENING_PAREN 5 | %token CLOSING_PAREN 6 | %token COMMA 7 | %token EOF 8 | 9 | %start guard 10 | %% 11 | 12 | guard: 13 | | expr = expr EOF { expr } 14 | 15 | expr: 16 | | e1 = expr op = INFIX_OP e2 = expr { Guard.Apply ("(" ^ op ^ ")", [e1; e2]) } 17 | | fn = ID OPENING_PAREN 18 | args = separated_nonempty_list(COMMA, expr) 19 | CLOSING_PAREN 20 | { Guard.Apply (fn, args) } 21 | | OPENING_PAREN e = expr CLOSING_PAREN { e } 22 | | var = ID { Guard.Variable var } 23 | | number = NUMBER { Guard.Litt_integer number } 24 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/parsed_patches.mli: -------------------------------------------------------------------------------- 1 | type header = { 2 | meta_expr : string list; 3 | name : string; 4 | guard : Guard.t list; 5 | keyvals : string SUStringMap.t; 6 | } 7 | 8 | type body = Automaton.A.state 9 | 10 | type patch = { 11 | header: header; 12 | body: body; 13 | } 14 | 15 | type unprocessed_header = header 16 | type unprocessed_body = Parsetree.expression 17 | type unprocessed_patch = { 18 | unprocessed_header : unprocessed_header; 19 | unprocessed_body : unprocessed_body; 20 | } 21 | 22 | type setting = 23 | | Expressions of string list 24 | | KeyVal of string * string 25 | | Name of string 26 | | Guard of Guard.t 27 | 28 | type t = patch 29 | 30 | val get_name : t -> string 31 | val get_msg : t -> string option 32 | val get_metavariables : t -> string list 33 | val get_guard : t -> Guard.t list 34 | 35 | val get_body : t -> body 36 | 37 | val void_header : header 38 | val header_from_list : setting list -> header 39 | 40 | val preprocess : unprocessed_patch -> t 41 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/patch_parser.mly: -------------------------------------------------------------------------------- 1 | %token EOF 2 | %token EOL 3 | %token COLON 4 | %token COMMA 5 | %token ID 6 | 7 | %token CODE 8 | 9 | %token TITLE_DELIM 10 | 11 | %token EXPR_KW 12 | %token NAME_KW 13 | %token GUARD_KW 14 | %token STRING 15 | %token NUMBER 16 | 17 | %start <(string * Parsed_patches.unprocessed_patch) list> sempatch 18 | %% 19 | 20 | sempatch: 21 | | eols_option patches = list(patch) EOF { patches } 22 | 23 | patch: 24 | | header = patch_header; body = patch_body 25 | { let open Parsed_patches in header.Parsed_patches.name, {unprocessed_header = header; unprocessed_body = body} } 26 | 27 | patch_header: 28 | | TITLE_DELIM name = ID eols fields = list(header_def) 29 | { Parsed_patches.header_from_list (Parsed_patches.Name name :: fields) } 30 | 31 | header_def: 32 | | EXPR_KW COLON exprs = separated_nonempty_list(COMMA, ID) eols 33 | { Parsed_patches.Expressions exprs } 34 | | NAME_KW COLON msg = string_or_id eols { Parsed_patches.Name msg } 35 | | GUARD_KW COLON guard = string_or_id eols 36 | { Parsed_patches.Guard 37 | (Guard_parser.guard Guard_lexer.read (Lexing.from_string guard)) 38 | } 39 | | key = ID COLON value = string_or_id eols { Parsed_patches.KeyVal (key, value) } 40 | 41 | patch_body: 42 | | cde = CODE eols 43 | { Raw_patch.to_patch_body 44 | (Code_parser.code Code_lexer.read_code (Lexing.from_string cde)) 45 | } 46 | 47 | eols: 48 | | nonempty_list(EOL) { } 49 | 50 | eols_option: 51 | | list(EOL) { } 52 | 53 | string_or_id: 54 | | s = STRING { s } 55 | | s = ID { s } 56 | | n = NUMBER { string_of_int n } 57 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/raw_patch.ml: -------------------------------------------------------------------------------- 1 | type patch_line = 2 | | EQUAL of string 3 | | ADD of string 4 | | REMOVE of string 5 | | SUBPATCH of t 6 | and t = patch_line list 7 | 8 | let inside expr = "[%__sempatch_inside " :: expr @ ["]"] 9 | let report expr = "[%__sempatch_report " :: expr @ ["]"] 10 | (* let replace expr replacement = "(" :: expr @ ") [@__sempatch_replace " *) 11 | (* :: replacement @ ["]"] *) 12 | let maybe_replace expr _replacement _has_change = expr 13 | (* if has_change then replace expr replacement *) 14 | (* else expr *) 15 | 16 | let to_patch_body p = 17 | let rec convert_line = function 18 | | [] -> ([], [], false) 19 | | l :: tl -> 20 | let (before, after, is_change) = convert_line tl in 21 | match l with 22 | | EQUAL l -> (l :: before, l :: after, is_change) 23 | | ADD l -> (before, l :: after, true) 24 | | REMOVE l -> (l :: before, after, true) 25 | | SUBPATCH p -> (convert_patch p @ before, after, is_change) 26 | and convert_patch p = 27 | let (before, after, has_change) = convert_line p in 28 | inside ( 29 | report ( 30 | maybe_replace before after has_change 31 | ) 32 | ) 33 | in 34 | let patch = (* convert_patch p *) 35 | let (before, after, has_change) = convert_line p in 36 | report ( 37 | maybe_replace before after has_change 38 | ) 39 | in 40 | Parser.parse_expression Lexer.token (Lexing.from_string 41 | (String.concat "\n" @@ patch) 42 | ) 43 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/parsing/raw_patch.mli: -------------------------------------------------------------------------------- 1 | type patch_line = 2 | | EQUAL of string 3 | | ADD of string 4 | | REMOVE of string 5 | | SUBPATCH of t 6 | and t = patch_line list 7 | 8 | val to_patch_body : t -> Parsetree.expression 9 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/sempatch.mli: -------------------------------------------------------------------------------- 1 | module Ast_element: 2 | sig 3 | type t = Ast_element.t 4 | 5 | val to_string : t -> string 6 | 7 | val from_structure : Parsetree.structure -> t 8 | val from_expression : Parsetree.expression -> t 9 | end 10 | 11 | module Substitution: 12 | sig 13 | type t 14 | 15 | val get : string -> t -> Ast_element.t option 16 | 17 | val to_list : t -> (string * Ast_element.t) list 18 | end 19 | 20 | module Match: 21 | sig 22 | type t (* = Environment.t *) 23 | 24 | (** Return the name of the patch who matched *) 25 | val get_patch_name : t -> string 26 | 27 | (** Return the location of the match *) 28 | val get_location : t -> Location.t 29 | 30 | (** Return the stubstitution of all the free variables in the patch *) 31 | val get_substitutions : t -> Substitution.t 32 | 33 | (** Return the matched ast element after application of the patch *) 34 | (* val get_patched_tree : t -> Ast_element.t *) (* When implemented *) 35 | end 36 | 37 | module Patch: 38 | sig 39 | type t (* = Parsed_patches.Typ.t *) 40 | 41 | (** Generate a list of patches *) 42 | val from_channel : in_channel -> t list 43 | val from_lexbuf : Lexing.lexbuf -> t list 44 | 45 | (** Accessors for patch metadatas *) 46 | val get_name : t -> string 47 | val get_msg : t -> string option 48 | val get_metavariables : t -> string list 49 | val get_field : string -> t -> string option 50 | 51 | (** {2 Application of patches} *) 52 | 53 | (** [apply patch tree] applyes [patch] to [tree] 54 | and returns the list of matches *) 55 | val apply : t -> Ast_element.t -> Match.t list 56 | 57 | (** [parallel_apply patches tree] applies all the patches to [tree] and 58 | returns the concatenation of all the matches 59 | *) 60 | val parallel_apply : t list -> Ast_element.t -> Match.t list 61 | end 62 | 63 | module Failure: 64 | sig 65 | type t 66 | 67 | exception SempatchException of t 68 | val to_string : t -> string 69 | end 70 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUError.ml: -------------------------------------------------------------------------------- 1 | type (+'good, +'bad) t = 2 | | IsOk of 'good 3 | | IsError of 'bad 4 | 5 | let return x = IsOk x 6 | let fail x = IsError x 7 | 8 | let map2 f_ok f_fail = function 9 | | IsOk x -> IsOk (f_ok x) 10 | | IsError e -> IsError (f_fail e) 11 | 12 | let map f = map2 f SUFun.id 13 | let map_err f x = map2 SUFun.id f x 14 | 15 | let bind2 f_ok f_fail = function 16 | | IsOk x -> f_ok x 17 | | IsError e -> f_fail e 18 | 19 | let bind f = bind2 f fail 20 | let bind_err f x = bind2 return f x 21 | 22 | let ok_if cond ok_val err_val = 23 | if cond then IsOk ok_val else IsError err_val 24 | 25 | module Ok_monad_infix = 26 | struct 27 | let (>>=) x f = bind f x 28 | let (>|=) x f = map f x 29 | end 30 | module Err_monad_infix = 31 | struct 32 | let (>>=) x f = bind_err f x 33 | let (>|=) x f = map_err f x 34 | end 35 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUError.mli: -------------------------------------------------------------------------------- 1 | type ('good, 'bad) t = 2 | | IsOk of 'good 3 | | IsError of 'bad 4 | 5 | val return : 'a -> ('a, 'err) t 6 | val fail : 'a -> ('ok, 'a) t 7 | 8 | val map : ('a -> 'b) -> ('a, 'err) t -> ('b, 'err) t 9 | val map_err : ('a -> 'b) -> ('ok, 'a) t -> ('ok, 'b) t 10 | 11 | val bind : ('a -> ('b, 'err) t) -> ('a, 'err) t -> ('b, 'err) t 12 | val bind_err : ('a -> ('ok, 'b) t) -> ('ok, 'a) t -> ('ok, 'b) t 13 | 14 | val ok_if : bool -> 'a -> 'b -> ('a, 'b) t 15 | 16 | module Ok_monad_infix : 17 | sig 18 | val (>>=) : ('a, 'err) t -> ('a -> ('b, 'err) t) -> ('b, 'err) t 19 | val (>|=) : ('a, 'err) t -> ('a -> 'b) -> ('b, 'err) t 20 | end 21 | module Err_monad_infix : 22 | sig 23 | val (>|=) : ('ok, 'a) t -> ('a -> 'b) -> ('ok, 'b) t 24 | val (>>=) : ('ok, 'a) t -> ('a -> ('ok, 'b) t) -> ('ok, 'b) t 25 | end 26 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUFun.ml: -------------------------------------------------------------------------------- 1 | let flip f x y = f y x 2 | let compose f g x = f (g x) 3 | 4 | let ( %> ) = compose 5 | 6 | let id x = x 7 | let const x _ = x 8 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUFun.mli: -------------------------------------------------------------------------------- 1 | val flip : ('a -> 'b -> 'c) -> ('b -> 'a -> 'c) 2 | 3 | val compose : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c) 4 | val ( %> ) : ('b -> 'c) -> ('a -> 'b) -> ('a -> 'c) 5 | 6 | val id : 'a -> 'a 7 | val const : 'a -> 'b -> 'a 8 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUList.ml: -------------------------------------------------------------------------------- 1 | include List 2 | 3 | type 'a t = 'a list 4 | 5 | let foldmap foldFun mapFun ini = 6 | SUFun.compose 7 | (List.fold_left foldFun ini) 8 | (List.map mapFun) 9 | 10 | let foldmap2_exn foldFun mapFun ini l = 11 | SUFun.compose 12 | (List.fold_left foldFun ini) 13 | (List.map2 mapFun l) 14 | 15 | let cons e l = e::l 16 | 17 | let sum = map2 18 | 19 | let rec take n l = match n, l with 20 | | 0, _ -> Some [] 21 | | n, (hd::tl) when n > 0 -> 22 | SUOption.bind (take (n-1) tl) (fun l -> Some (cons hd l)) 23 | | _ -> None 24 | 25 | let truncate_as l1 l2 = 26 | let new_length = List.length l2 in 27 | take new_length l1 28 | 29 | let bind f lst = List.map f lst |> List.flatten 30 | let product_bind f l1 l2 = bind (fun x -> bind (f x) l2) l1 31 | let product f l1 l2 = product_bind (fun x y -> [f x y]) l1 l2 32 | 33 | let flip_opt list = List.fold_left (fun accu elt -> 34 | match accu, elt with 35 | | Some acc, Some el -> Some (el::acc) 36 | | _ -> None 37 | ) 38 | (Some []) 39 | list 40 | 41 | let find_opt f l = try List.find f l |> SUOption.some with Not_found -> None 42 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUList.mli: -------------------------------------------------------------------------------- 1 | include module type of List 2 | 3 | type 'a t = 'a list 4 | 5 | val foldmap: ('c -> 'b -> 'c) -> ('a -> 'b) -> 'c -> 'a t -> 'c 6 | val foldmap2_exn: 7 | ('c -> 'b -> 'c) -> 8 | ('a -> 'd -> 'b) -> 9 | 'c -> 'a t -> 'd t -> 'c 10 | 11 | val cons : 'a -> 'a list -> 'a list 12 | 13 | val truncate_as : 'a list -> 'b list -> 'a list option 14 | 15 | val bind : ('a -> 'b t) -> 'a t -> 'b t 16 | val sum : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list 17 | val product : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list 18 | val product_bind : ('a -> 'b -> 'c t) -> 'a list -> 'b list -> 'c list 19 | 20 | val flip_opt : 'a option list -> 'a list option 21 | 22 | val find_opt : ('a -> bool) -> 'a list -> 'a option 23 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUMessages.ml: -------------------------------------------------------------------------------- 1 | let out_fun = 2 | try 3 | ignore @@ Sys.getenv "SEMPATCH_VERBOSE"; 4 | print_string 5 | with Not_found -> ignore 6 | 7 | let debug msg = Printf.ksprintf 8 | (fun msg -> out_fun ("Debug : " ^ msg)) 9 | msg 10 | 11 | let warn msg = Printf.ksprintf 12 | (fun msg -> out_fun ("Warning : " ^ msg)) 13 | msg 14 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUMessages.mli: -------------------------------------------------------------------------------- 1 | val debug : ('a, unit, string, unit) format4 -> 'a 2 | val warn : ('a, unit, string, unit) format4 -> 'a 3 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUMisc.ml: -------------------------------------------------------------------------------- 1 | let pair a b = a,b 2 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUMisc.mli: -------------------------------------------------------------------------------- 1 | val pair: 'a -> 'b -> 'a*'b 2 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUOption.ml: -------------------------------------------------------------------------------- 1 | type 'a t = 'a option 2 | 3 | let bind x f = match x with 4 | | None -> None 5 | | Some x -> f x 6 | 7 | let map f x = bind x (fun x -> Some (f x)) 8 | 9 | let iter f x = ignore (map f x) 10 | 11 | let merge_sup f o1 o2 = match o1, o2 with 12 | | Some x, Some y -> Some (f x y) 13 | | Some x, _ -> Some x 14 | | _ -> o2 15 | 16 | let merge_inf f o1 o2 = match o1, o2 with 17 | | Some x, Some y -> Some (f x y) 18 | | _ -> None 19 | 20 | let zip o1 o2 = merge_inf SUMisc.pair o1 o2 21 | 22 | let value default = function 23 | | None -> default 24 | | Some x -> x 25 | 26 | let (|?) opt default = value default opt 27 | 28 | let fold f init = let open SUFun in 29 | value init %> map (f init) 30 | 31 | let some x = Some x 32 | let none = None 33 | 34 | let some_if cond x = if cond then Some x else None 35 | 36 | let is_none x = (=) None x 37 | let is_some x = (<>) None x 38 | 39 | let to_list = function 40 | | Some x -> [x] 41 | | None -> [] 42 | 43 | module Infix = 44 | struct 45 | let (|?) = (|?) 46 | let (>>=) = bind 47 | let (>|=) x y = map y x 48 | end 49 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUOption.mli: -------------------------------------------------------------------------------- 1 | type 'a t = 'a option 2 | 3 | val map : ('a -> 'b) -> 'a t -> 'b t 4 | val iter : ('a -> unit) -> 'a t -> unit 5 | 6 | val merge_sup : ('a -> 'a -> 'a) -> 'a t -> 'a t -> 'a t 7 | val merge_inf : ('a -> 'b -> 'c) -> 'a t -> 'b t -> 'c t 8 | 9 | val zip : 'a t -> 'b t -> ('a * 'b) t 10 | 11 | val value: 'a -> 'a t -> 'a 12 | 13 | val fold: ('a -> 'b -> 'a) -> 'a -> 'b option -> 'a 14 | 15 | val some : 'a -> 'a t 16 | val none : 'a t 17 | val some_if : bool -> 'a -> 'a t 18 | 19 | val is_some : 'a t -> bool 20 | val is_none : 'a t -> bool 21 | 22 | val bind : 'a t -> ('a -> 'b t) -> 'b t 23 | 24 | val to_list : 'a t -> 'a list 25 | 26 | module Infix : 27 | sig 28 | val (|?) : 'a t -> 'a -> 'a 29 | val (>>=) : 'a t -> ('a -> 'b t) -> 'b t 30 | val (>|=) : 'a t -> ('a -> 'b) -> 'b t 31 | end 32 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUStringMap.ml: -------------------------------------------------------------------------------- 1 | module M = Map.Make(String) 2 | include M 3 | 4 | let from_list_pair l = 5 | List.fold_left 6 | (fun map (k, e) -> M.add k e map) 7 | M.empty 8 | l 9 | 10 | let get k sm = 11 | try 12 | Some (M.find k sm) 13 | with Not_found -> None 14 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/sUStringMap.mli: -------------------------------------------------------------------------------- 1 | include Map.S with type key = string 2 | val from_list_pair : (string * 'a) list -> 'a t 3 | val get : string -> 'a t -> 'a option 4 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/std_utils/std_utils.ml: -------------------------------------------------------------------------------- 1 | module Misc = SUMisc 2 | module Fun = SUFun 3 | module Option = SUOption 4 | module Error = SUError 5 | module List = SUList 6 | module StringMap = SUStringMap 7 | module Messages = SUMessages 8 | -------------------------------------------------------------------------------- /libs/ocplib-sempatch/lib/substitution.mli: -------------------------------------------------------------------------------- 1 | open Std_utils 2 | 3 | type t = Ast_element.t StringMap.t 4 | 5 | val empty: t 6 | 7 | val get: string -> t -> Ast_element.t option 8 | val get_expr: string -> t -> Parsetree.expression option 9 | val get_ident: string -> t -> string option 10 | 11 | val add_expr: string -> Parsetree.expression -> t -> t 12 | val add_ident: string -> string -> t -> t 13 | val add_pattern: string -> Parsetree.pattern -> t -> t 14 | 15 | val to_list : t -> (string * Ast_element.t) list 16 | 17 | val merge: t -> t -> t 18 | -------------------------------------------------------------------------------- /opam: -------------------------------------------------------------------------------- 1 | (**************************************************************) 2 | (* *) 3 | (* This file is managed by ocp-autoconf *) 4 | (* Remove it from `manage_files` in 'ocp-autoconf.config' *) 5 | (* if you want to modify it manually (or use 'opam.trailer') *) 6 | (* *) 7 | (**************************************************************) 8 | 9 | opam-version: "1.2" 10 | maintainer: "OCamlPro " 11 | authors: [ 12 | "OCamlPro " 13 | ] 14 | homepage: "http://github.com/OCamlPro/typerex-lint" 15 | dev-repo: "https://github.com/OCamlPro/typerex-lint.git" 16 | bug-reports: "https://github.com/OCamlPro/typerex-lint/issues" 17 | build: [ 18 | [ "./configure" 19 | "--prefix" 20 | "%{prefix}%" 21 | "--with-ocamldir=%{prefix}%/lib" 22 | "--with-metadir=%{prefix}%/lib" 23 | ] 24 | [ make ] 25 | ] 26 | install: [ 27 | [ make "install" ] 28 | ] 29 | remove: [ 30 | [ "make" "uninstall" ] 31 | ] 32 | depends: [ 33 | "js_of_ocaml" 34 | "js_of_ocaml-camlp4" 35 | "js_of_ocaml-tyxml" 36 | "lwt" 37 | "menhir" 38 | "ocamlfind" 39 | "ocp-build" {>= "1.99.20-beta" } 40 | "ocp-indent" 41 | "omd" 42 | "ppx_tools" 43 | "tyxml" 44 | "yojson" 45 | ] 46 | available: [ocaml-version >= "4.02.3"] 47 | -------------------------------------------------------------------------------- /plugins/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains some plugins for `ocp-lint`: 2 | 3 | * `ocp-lint-plugin-files`: analyses working on relationships between files 4 | * `ocp-lint-plugin-text`: analyses working on source text 5 | * `ocp-lint-plugin-parsing`: analyses working at parsing phase 6 | * `ocp-lint-plugin-parsetree`: analyses working on parsetree (AST) 7 | * `ocp-lint-plugin-typedtree`: analyses working on typedtree (typed AST) 8 | * `ocp-lint-plugin-complex`: analyses working on multiple sources 9 | * `ocp-lint-plugin-sempatch`: analyses using semantic patches 10 | -------------------------------------------------------------------------------- /plugins/make_db_test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TESTDIR='/tests' 3 | CFG='../../../testsuite/.ocplint' 4 | for i in `ls`; 5 | do 6 | if [ -d "$i$TESTDIR" ]; then 7 | cd $i$TESTDIR; 8 | cp $CFG .; 9 | rm -rf _olint/*; 10 | for j in `ls`; 11 | do 12 | if [ -d "$j" ]; then 13 | if [ "$j" != "_olint" ]; then 14 | if [ "$i" != "ocp-lint-plugin-sempatch" ]; then 15 | echo "script : [`pwd`] ocp-lint.asm --path $j"; 16 | rm -rf _olint/*; 17 | rm -rf $j/ocp-lint.result; 18 | ../../../_obuild/ocp-lint/ocp-lint.asm --path $j; 19 | cp -rf _olint/ $j/ocp-lint.result; 20 | echo "script : [`pwd`] ocp-lint.asm --print-db $j/ocp-lint.result"; 21 | ../../../_obuild/ocp-lint/ocp-lint.asm --print-db $j/ocp-lint.result; 22 | else 23 | if [ -e "$j/sempatch.md" ]; then 24 | echo "script : [`pwd`] ocp-lint.asm --path $j"; 25 | rm -rf _olint/*; 26 | rm -rf $j/ocp-lint.result; 27 | OCPLINT_PATCHES=$j/ ../../../_obuild/ocp-lint/ocp-lint.asm --path $j; 28 | cp -rf _olint/ $j/ocp-lint.result; 29 | echo "script : [`pwd`] ocp-lint.asm --print-db $j/ocp-lint.result"; 30 | ../../../_obuild/ocp-lint/ocp-lint.asm --print-db $j/ocp-lint.result; 31 | else 32 | echo "script : [`pwd`] ocp-lint.asm --path $j"; 33 | rm -rf _olint/*; 34 | rm -rf $j/ocp-lint.result; 35 | ../../../_obuild/ocp-lint/ocp-lint.asm --path $j; 36 | cp -rf _olint/ $j/ocp-lint.result; 37 | echo "script : [`pwd`] ocp-lint.asm --print-db $j/ocp-lint.result"; 38 | ../../../_obuild/ocp-lint/ocp-lint.asm --print-db $j/ocp-lint.result; 39 | fi 40 | fi 41 | fi 42 | fi 43 | done; 44 | cd -; 45 | fi 46 | done 47 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-plugin-complex" 22 | install_META = true 23 | install_subdir = "ocp-lint-plugins" 24 | files = [ 25 | "plugin_complex.ml" 26 | 27 | (* All linters attached to Parsetree plugin. *) 28 | "interface_module_type_name.ml" 29 | ] 30 | requires = [ 31 | "ocp-lint-config" 32 | "ocp-lint-api" 33 | "ocplib-compiler" 34 | ] 35 | end 36 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/plugin_complex.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let details = 22 | "A plugin with linters on different inputs" 23 | 24 | module PluginComplex = Lint_plugin_api.MakePlugin (struct 25 | let name = "Complex plugin" 26 | let short_name = "plugin_complex" 27 | let details = details 28 | let enabled = true 29 | end) 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-complex" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/tests/module_type_name/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_complex = { 12 | enabled = true 13 | interface_module_type_name = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/tests/module_type_name/ocp-lint.result/2d1e84397f8aec6661adbf688ce7b73a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-complex/tests/module_type_name/ocp-lint.result/2d1e84397f8aec6661adbf688ce7b73a -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/tests/module_type_name/ocp-lint.result/33145cbee016a553d5385ef2bf540c54: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-complex/tests/module_type_name/ocp-lint.result/33145cbee016a553d5385ef2bf540c54 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/tests/module_type_name/test_module_type_name.ml: -------------------------------------------------------------------------------- 1 | module type CORRECT = sig 2 | val value : string 3 | end 4 | 5 | module type NotCorrect = sig 6 | val value : string 7 | end 8 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-complex/tests/module_type_name/test_module_type_name.mli: -------------------------------------------------------------------------------- 1 | module type CORRECT = sig 2 | val value : string 3 | end 4 | 5 | module type NotCorrect = sig 6 | val value : string 7 | end 8 | 9 | module type NOT_cORRECT = sig 10 | val value : string 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-files/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-plugin-files" 22 | install_META = true 23 | install_subdir = "ocp-lint-plugins" 24 | files = [ 25 | "plugin_file_system.ml" 26 | 27 | (* All linters attached to File System plugin. *) 28 | "interface_missing.ml" 29 | "project_files.ml" 30 | ] 31 | requires = [ 32 | "ocp-lint-config" 33 | "ocp-lint-api" 34 | ] 35 | end 36 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-files/plugin_file_system.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let details = 22 | "A plugin with linters on file system like interface missing, etc" 23 | 24 | module PluginFileSystem = Lint_plugin_api.MakePlugin (struct 25 | let name = "File System plugin" 26 | let short_name = "plugin_file_system" 27 | let details = details 28 | let enabled = true 29 | end) 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-files/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-files" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-files/tests/interface_missing/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_file_system = { 12 | enabled = true 13 | interface_missing = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-files/tests/interface_missing/ocp-lint.result/06e08076b07bd84b1d19c9c5f869ca4d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-files/tests/interface_missing/ocp-lint.result/06e08076b07bd84b1d19c9c5f869ca4d -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-files/tests/interface_missing/test_interface_missing.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let my_function arg = arg + 1 22 | 23 | let _ = 24 | let res = my_function 0 in 25 | Printf.printf "%i" res 26 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-plugin-indent" 22 | (* Uncomment when: *) 23 | (* * ocp-indent'META has field plugin *) 24 | (* * ocp-intent installs its .cmxs *) 25 | (* install_META = true *) 26 | (* install_subdir = "ocp-lint-plugins" *) 27 | files = [ 28 | "plugin_indent.ml" 29 | "ocp_indent.ml" 30 | ] 31 | requires = [ 32 | "ocp-lint-config" 33 | "ocp-lint-api" 34 | "ocp-indent.lib" 35 | ] 36 | end 37 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/plugin_indent.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let details = 22 | "A plugin with linters on the source" 23 | 24 | module Plugin = Lint_plugin_api.MakePlugin (struct 25 | let name = "Indentation of code plugin" 26 | let short_name = "plugin_indent" 27 | let details = details 28 | let enabled = true 29 | end) 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-indent" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/tests/ocp_indent/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_text = { 12 | enabled = true 13 | ocp_indent = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/4d4b5217df862462ae39042a1dade445: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/4d4b5217df862462ae39042a1dade445 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/566910322489a75fde76df5112fe7999: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/566910322489a75fde76df5112fe7999 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/9f85cae42d6265c02d4cdbbe80cc0ee1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/9f85cae42d6265c02d4cdbbe80cc0ee1 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/cf5282d2ebef628872c880f0730e92aa: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-indent/tests/ocp_indent/ocp-lint.result/cf5282d2ebef628872c880f0730e92aa -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-indent/tests/ocp_indent/test_ocp_indent.ml: -------------------------------------------------------------------------------- 1 | 2 | 3 | let my_fun arg = 4 | arg + 1 5 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/plugin_parsetree.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let details = 22 | "A plugin with linters on parsetree" 23 | 24 | module Plugin = Lint_plugin_api.MakePlugin (struct 25 | let name = "Parsetree plugin" 26 | let short_name = "plugin_parsetree" 27 | let details = details 28 | let enabled = true 29 | end) 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-parsetree" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/identifier_length/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_parsetree = { 12 | enabled = true 13 | code_identifier_length = { 14 | enabled = true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/identifier_length/ocp-lint.result/7d7e4e04dacf6d2b16f9bc90ebf9c802: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-parsetree/tests/identifier_length/ocp-lint.result/7d7e4e04dacf6d2b16f9bc90ebf9c802 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/identifier_length/test_identifier_length.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let f a b = a + b 22 | 23 | let very_very_very_long_long_variable_name1 = 2 24 | 25 | let very_very_very_long_long_variable_name2 = 3 26 | 27 | let _ = 28 | let very_long_variable_name1 = 2 in 29 | let very_long_variable_name2 = 3 in 30 | let pattern = Some 1 in 31 | match pattern with 32 | | Some very_long_variable_name3 -> () 33 | | None -> () 34 | 35 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/list_fun_on_singleton/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_parsetree = { 12 | enabled = true 13 | code_list_on_singleton = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/list_fun_on_singleton/ocp-lint.result/6dea8cfb1a7de94d5f362d6548c55948: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-parsetree/tests/list_fun_on_singleton/ocp-lint.result/6dea8cfb1a7de94d5f362d6548c55948 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/physical_comp_on_allocated_lit/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_parsetree = { 12 | enabled = true 13 | phys_comp_allocated_lit = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/physical_comp_on_allocated_lit/ocp-lint.result/83f1ad17f3d27d1004a7ce287bce32a3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-parsetree/tests/physical_comp_on_allocated_lit/ocp-lint.result/83f1ad17f3d27d1004a7ce287bce32a3 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/physical_comp_on_allocated_lit/test_phys_comp_on_allocated_lit.ml: -------------------------------------------------------------------------------- 1 | 2 | type t = { id : int; message : string} 3 | 4 | let my_fun () = 5 | ignore (1 == 1); 6 | ignore ("toto" == "titi"); 7 | ignore ((1, 2) == (1, 2)); 8 | ignore (Some (1,2) == Some (1, 2)); 9 | ignore ({id = 1; message = "message 1"} == {id = 1; message = "message 1"}); 10 | ignore ([|1; 2; 3;|] == [|1; 2; 3|]) 11 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_parsetree = { 12 | enabled = true 13 | code_redefine_stdlib_module = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/config.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/config.ml -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/ocp-lint.result/8c794107745dd52f38ec72d064978d6a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/ocp-lint.result/8c794107745dd52f38ec72d064978d6a -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/ocp-lint.result/f87a9ba7d82e0113f012a8b023b1efce: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/ocp-lint.result/f87a9ba7d82e0113f012a8b023b1efce -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsetree/tests/redefine_std_lib/test_redefine_std_lib.ml: -------------------------------------------------------------------------------- 1 | module Pervasives = struct end 2 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/.gitignore: -------------------------------------------------------------------------------- 1 | lintParsing_Asttypes.ml 2 | lintParsing_Parsetree.ml 3 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/apply-patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Use ./gen-patch.sh to generate the patch 4 | 5 | OLD_VERSION=4.03.0 6 | VERSION=4.03.0 7 | SOURCEDIR=${HOME}/BUILD/ocaml-${VERSION} 8 | 9 | echo Applying patch lint-parsing-${OLD_VERSION}.patch into ${VERSION}.orig/ 10 | 11 | FILES="\ 12 | parsing/ast_helper.ml \ 13 | parsing/ast_iterator.ml \ 14 | parsing/ast_iterator.mli \ 15 | parsing/asttypes.mli \ 16 | parsing/docstrings.ml \ 17 | parsing/lexer.mll \ 18 | parsing/location.ml \ 19 | parsing/parse.ml \ 20 | parsing/parse.mli \ 21 | parsing/parser.mly \ 22 | parsing/parsetree.mli \ 23 | parsing/syntaxerr.ml" 24 | 25 | rm -rf ${VERSION}.orig 26 | mkdir ${VERSION}.orig 27 | 28 | for file in ${FILES}; do 29 | basefile=$(basename ${file}) 30 | module=$(echo $basefile | sed 's/./\U&/') 31 | cp ${SOURCEDIR}/${file} ${VERSION}.orig/lintParsing_${module} 32 | done 33 | 34 | cd ${VERSION}.orig 35 | patch -p1 < ../lint-parsing-${OLD_VERSION}.patch 36 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/gen-patch.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | VERSION=4.03.0 4 | SOURCEDIR=${HOME}/BUILD/ocaml-${VERSION} 5 | FILES="\ 6 | parsing/ast_helper.ml \ 7 | parsing/ast_iterator.ml \ 8 | parsing/ast_iterator.mli \ 9 | parsing/asttypes.mli \ 10 | parsing/docstrings.ml \ 11 | parsing/lexer.mll \ 12 | parsing/location.ml \ 13 | parsing/parse.ml \ 14 | parsing/parse.mli \ 15 | parsing/parser.mly \ 16 | parsing/parsetree.mli \ 17 | parsing/syntaxerr.ml" 18 | 19 | rm -rf ${VERSION}.orig ${VERSION}.new 20 | mkdir ${VERSION}.orig 21 | mkdir ${VERSION}.new 22 | 23 | for file in ${FILES}; do 24 | echo ${file} 25 | basefile=$(basename ${file}) 26 | module=$(echo $basefile | sed 's/./\U&/') 27 | echo ${module} 28 | cp ${SOURCEDIR}/${file} ${VERSION}.orig/lintParsing_${module} 29 | cp lintParsing_${module} ${VERSION}.new/ 30 | done 31 | 32 | diff -w -b -C 2 ${VERSION}.orig ${VERSION}.new > lint-parsing-${VERSION}.patch 33 | 34 | rm -rf ${VERSION}.new ${VERSION}.old 35 | cat lint-parsing-${VERSION}.patch 36 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/lintParsingPlugin.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let plugin_name = "Parsing Linter" 22 | 23 | let details = "Analyses requiring to re-parse the file" 24 | 25 | module Plugin = Lint_plugin_api.MakePlugin (struct 26 | let name = plugin_name 27 | let short_name = "plugin_parsing" 28 | let details = details 29 | let enabled = true 30 | end) 31 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/lintParsing_Parse.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCaml *) 4 | (* *) 5 | (* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) 6 | (* *) 7 | (* Copyright 1996 Institut National de Recherche en Informatique et *) 8 | (* en Automatique. *) 9 | (* *) 10 | (* All rights reserved. This file is distributed under the terms of *) 11 | (* the GNU Lesser General Public License version 2.1, with the *) 12 | (* special exception on linking described in the file LICENSE. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | module Asttypes = LintParsing_Asttypes 17 | module Ast_helper = LintParsing_Ast_helper 18 | module Parsetree = LintParsing_Parsetree 19 | module Docstrings = LintParsing_Docstrings 20 | module Location = LintParsing_Location 21 | module Syntaxerr = LintParsing_Syntaxerr 22 | module Lexer = LintParsing_Lexer 23 | module Parser = LintParsing_Parser 24 | 25 | (* Entry points in the parser *) 26 | 27 | val implementation : Lexing.lexbuf -> Parsetree.structure 28 | val interface : Lexing.lexbuf -> Parsetree.signature 29 | val toplevel_phrase : Lexing.lexbuf -> Parsetree.toplevel_phrase 30 | val use_file : Lexing.lexbuf -> Parsetree.toplevel_phrase list 31 | val core_type : Lexing.lexbuf -> Parsetree.core_type 32 | val expression : Lexing.lexbuf -> Parsetree.expression 33 | val pattern : Lexing.lexbuf -> Parsetree.pattern 34 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/main.ml: -------------------------------------------------------------------------------- 1 | 2 | let () = Lint.main () 3 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/tests/.gitignore: -------------------------------------------------------------------------------- 1 | /test.current 2 | /_obuild 3 | /_olint 4 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/tests/.ocpstop: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/tests/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PLUGIN=ocp-lint-plugin-parsing 3 | OBUILD=../../../_obuild 4 | LINT=$(OBUILD)/ocp-lint/ocp-lint.asm --load-plugins $(OBUILD)/$(PLUGIN)/$(PLUGIN).cmxs 5 | 6 | all: 7 | rm -rf _obuild _olint 8 | ocp-build init 9 | ocp-build ocp-lint-plugin-parsing-test 10 | $(LINT) --init 11 | $(LINT) --path . > test.current 2>&1 12 | diff test.reference test.current && echo TEST OK || echo TEST FAILED 13 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-parsing" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/tests/test.ml: -------------------------------------------------------------------------------- 1 | 2 | let x = Pervasives.open_in 3 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-parsing/tests/test.reference: -------------------------------------------------------------------------------- 1 | Loading plugin "Parsing Linter" 2 | No DB file found, using a fresh DB 3 | Scanning files in project "."... 4 | Found '6' file(s) 5 | Starting analyses... 6 | plugin_parsing.raw_syntax: parsing ./test.ml 7 | Printing results... 8 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/plugin_patch.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | module PluginPatch = Lint_plugin_api.MakePlugin (struct 22 | let name = "Semantic patch plugin" 23 | let short_name = "plugin_patch" 24 | let details = "Detect pattern with semantic patch." 25 | let enabled = true 26 | end) 27 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-sempatch" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_backward_if/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_backward_if/ocp-lint.result/d08e9b505b422eb779cb21717ed422d1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_backward_if/ocp-lint.result/d08e9b505b422eb779cb21717ed422d1 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_backward_if/test_sempatch_backward_if.ml: -------------------------------------------------------------------------------- 1 | 2 | let my_fun cond expr = 3 | if cond then () else expr 4 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_false/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_false/ocp-lint.result/3be2d8938459aa4ecf1ca7f35d8ea31d: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_false/ocp-lint.result/3be2d8938459aa4ecf1ca7f35d8ea31d -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_false/test_sempatch_comp_to_false.ml: -------------------------------------------------------------------------------- 1 | 2 | let test_comp_to_false condition texpr fexpr = 3 | if condition = false then texpr 4 | else fexpr 5 | 6 | let test_comp_to_not_false condition texpr fexpr = 7 | if condition != false then texpr 8 | else fexpr 9 | 10 | let test_comp_to_phys_false condition texpr fexpr = 11 | if condition == false then texpr 12 | else fexpr 13 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_true/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_true/ocp-lint.result/866b4dd68fbcbb7c7ad4ab4b2fd11503: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_true/ocp-lint.result/866b4dd68fbcbb7c7ad4ab4b2fd11503 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_comp_to_true/test_sempatch_comp_to_true.ml: -------------------------------------------------------------------------------- 1 | 2 | let test_comp_to_true condition texpr fexpr = 3 | if condition = true then texpr 4 | else fexpr 5 | 6 | let test_comp_to_not_true condition texpr fexpr = 7 | if condition != true then texpr 8 | else fexpr 9 | 10 | let test_comp_to_phys_true condition texpr fexpr = 11 | if condition == true then texpr 12 | else fexpr 13 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_constant_if/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_constant_if/ocp-lint.result/75784dd883a4fe0bcc3293e8b54c4d93: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_constant_if/ocp-lint.result/75784dd883a4fe0bcc3293e8b54c4d93 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_constant_if/test_constant_if.ml: -------------------------------------------------------------------------------- 1 | 2 | let test_empty_list_cmp cond expr = 3 | if cond then expr else expr 4 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_empty_list_compare/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_empty_list_compare/ocp-lint.result/be780e4c73479987acccf2bc0487e652: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_empty_list_compare/ocp-lint.result/be780e4c73479987acccf2bc0487e652 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_empty_list_compare/test_sempatch_empty_list_cmp.ml: -------------------------------------------------------------------------------- 1 | 2 | let test_empty_list_cmp list texpr fexpr = 3 | (* Matched by @EmptyListComparison *) 4 | if List.length list = 0 then texpr 5 | else fexpr; 6 | if List.length list = 1 then texpr 7 | else fexpr; 8 | if List.length list = 2 then texpr 9 | else fexpr; 10 | if List.length list = 3 then texpr 11 | else fexpr; 12 | if List.length list = 4 then texpr 13 | else fexpr; 14 | if List.length list = 5 then texpr 15 | else fexpr; 16 | (* Not matched *) 17 | if List.length list = 6 then texpr 18 | else fexpr; 19 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_identity_let/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_identity_let/ocp-lint.result/897663146003983141984362715f3b92: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_identity_let/ocp-lint.result/897663146003983141984362715f3b92 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_identity_let/test_identity_let.ml: -------------------------------------------------------------------------------- 1 | 2 | let () = 3 | let var = 1 + 1 in 4 | var 5 | 6 | let () = 7 | let rec rec_var = 1 ::rec_var in 8 | rec_var 9 | 10 | let () = 11 | let vary = 4 in 12 | let varx = 1 + 2 in 13 | vary 14 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_incr_decr/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_incr_decr/ocp-lint.result/b413206f36fadacad9a83e5cdcd1caba: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_incr_decr/ocp-lint.result/b413206f36fadacad9a83e5cdcd1caba -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_incr_decr/test_sempatch_incr_decr.ml: -------------------------------------------------------------------------------- 1 | 2 | let test_incr () = 3 | let cpt = ref 0 in 4 | cpt := !cpt + 1 5 | 6 | let test_descr () = 7 | let cpt = ref 0 in 8 | cpt := !cpt - 1 9 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_parallel_let_bindings/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_parallel_let_bindings/ocp-lint.result/4444496085a17b45c9007c6fc3d24f19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_parallel_let_bindings/ocp-lint.result/4444496085a17b45c9007c6fc3d24f19 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_parallel_let_bindings/sempatch.md: -------------------------------------------------------------------------------- 1 | @Multiple_parallel_let 2 | ``` 3 | let _x = 1 and _y = 2 and _z = 3 in () 4 | ``` 5 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_parallel_let_bindings/test_parallel_let_bindings.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | let _x = 1 3 | and _y = 2 4 | and _z = 3 5 | in 6 | () 7 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_succ_pred/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | 13 | (* Detect pattern with semantic patch. *) 14 | enabled = true 15 | sempatch_lint_user_defined = { 16 | enabled = true 17 | warnings = "+A" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_succ_pred/ocp-lint.result/1f3f548f2e69a9d5a787221b9aa2cf80: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_succ_pred/ocp-lint.result/1f3f548f2e69a9d5a787221b9aa2cf80 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_succ_pred/sempatch.md: -------------------------------------------------------------------------------- 1 | @AddSmallInteger 2 | expressions: e1, e2 3 | when : "is_in_range(e2, -1, 1) && not(is_int_in_range(e2, -1, 1))" 4 | message : "use `succ`, `pred` or nothing instead of adding $e2" 5 | ``` 6 | add e1 e2 7 | ``` 8 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_succ_pred/test_sempatch_succ_pred.ml: -------------------------------------------------------------------------------- 1 | let _ = ignore (let add = Int32.add in add 1l 1l) 2 | let _ = ignore (let add = Int64.add in add 1L 1L) 3 | let _ = ignore (let add = Nativeint.add in add 0n 1n) 4 | let _ = let add = (+) in ignore (add 0 1) 5 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_test_list_op_on_lit/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_test_list_op_on_lit/ocp-lint.result/b1e981b56e350a82c813f0beba0db8b9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_test_list_op_on_lit/ocp-lint.result/b1e981b56e350a82c813f0beba0db8b9 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_test_list_op_on_lit/test_sempatch_list_op_on_lit.ml: -------------------------------------------------------------------------------- 1 | 2 | let my_fun expr list = 3 | let _list = [] @ _list in 4 | let _list = [expr] @ _list in 5 | let _list = _list @ [] in 6 | let _list = _list @ [expr] in 7 | _list @ _list 8 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_traverse_nodes/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | 13 | (* Detect pattern with semantic patch. *) 14 | enabled = true 15 | sempatch_lint_user_defined = { 16 | enabled = true 17 | warnings = "+A" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_traverse_nodes/ocp-lint.result/65ff12f9029c7c14b4928167bfde08ea: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_traverse_nodes/ocp-lint.result/65ff12f9029c7c14b4928167bfde08ea -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_traverse_nodes/sempatch.md: -------------------------------------------------------------------------------- 1 | @FindAllFoos 2 | message : found 3 | ``` 4 | foo 5 | ``` 6 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_traverse_nodes/test_sempatch_traverse_nodes.ml: -------------------------------------------------------------------------------- 1 | let foo foo = (* Inside top-level let-binding *) 2 | let _ = foo (* (multiple) let bindings *) 3 | and _ = foo 4 | in 5 | ignore foo; (* Simple var *) 6 | ignore (Some foo); (* Inside constructor *) 7 | ignore ((fun _ -> foo) foo); (* Inside fun definition && application *) 8 | function (* Inside function body and guards *) 9 | | _ when foo -> foo 10 | | _ -> foo 11 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_else/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_else/ocp-lint.result/66ca2da272df0568b40e918f2f0dfac9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_else/ocp-lint.result/66ca2da272df0568b40e918f2f0dfac9 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_else/test_sempatch_useless_else.ml: -------------------------------------------------------------------------------- 1 | 2 | let my_fun cond expr = 3 | if cond then expr else () 4 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_if/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_patch = { 12 | enabled = true 13 | sempatch_lint_default = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_if/ocp-lint.result/1b78a7f1828148dd946df9b5fcaaf4ac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_if/ocp-lint.result/1b78a7f1828148dd946df9b5fcaaf4ac -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-sempatch/tests/sempatch_useless_if/test_sempatch_useless_if.ml: -------------------------------------------------------------------------------- 1 | 2 | let test_empty_list_cmp cond = 3 | if cond then true else false 4 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-text/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-plugin-text" 22 | install_META = true 23 | install_subdir = "ocp-lint-plugins" 24 | files = [ 25 | "plugin_text.ml" 26 | 27 | (* All linters attached to Text plugin. *) 28 | "code_length.ml" 29 | "useless_space.ml" 30 | "not_that_char.ml" 31 | ] 32 | requires = [ 33 | "ocp-lint-config" 34 | "ocp-lint-api" 35 | ] 36 | end 37 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-text/plugin_text.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let details = 22 | "A plugin with linters on the source" 23 | 24 | module Plugin = Lint_plugin_api.MakePlugin (struct 25 | let name = "Source code plugin" 26 | let short_name = "plugin_text" 27 | let details = details 28 | let enabled = true 29 | end) 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-text/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-text" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-text/tests/code_length/.ocplint: -------------------------------------------------------------------------------- 1 | 2 | 3 | (*************************************) 4 | (* Never edit options files while *) 5 | (* the program is running *) 6 | (*************************************) 7 | (* SECTION : Header *) 8 | (* These options must be read first *) 9 | (*************************************) 10 | 11 | plugin_text = { 12 | enabled = true 13 | code_length = { 14 | enabled = true 15 | } 16 | } -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-text/tests/code_length/ocp-lint.result/21a080aedc1da1f0a11c1121fdec16b6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/plugins/ocp-lint-plugin-text/tests/code_length/ocp-lint.result/21a080aedc1da1f0a11c1121fdec16b6 -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-text/tests/code_length/test_code_length.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let a = 22 | 1 23 | + 3 24 | 25 | (* A very long comment *) 26 | 27 | let long_exp_in_fun = function 28 | | Some _ -> "this is a very long string which should trigger a warning in code_length" 29 | | None -> "" 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-tokens/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-plugin-tokens" 22 | install_META = true 23 | install_subdir = "ocp-lint-plugins" 24 | files = [ 25 | "plugin_tokens.ml" 26 | 27 | "checkTokens.ml" 28 | ] 29 | requires = [ 30 | "ocp-lint-config" 31 | "ocp-lint-api" 32 | "ocplib-compiler" 33 | ] 34 | end 35 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-tokens/plugin_tokens.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let details = 22 | "A plugin with linters on lexer tokens" 23 | 24 | module Plugin = Lint_plugin_api.MakePlugin (struct 25 | let name = "Tokens plugin" 26 | let short_name = "plugin_tokens" 27 | let details = details 28 | let enabled = true 29 | end) 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/checkIdentifierMasking.ml: -------------------------------------------------------------------------------- 1 | module Linter = Plugin_typedtree.Plugin.MakeLint(struct 2 | let name = "Identifier Masking" 3 | let version = "1" 4 | let short_name = "identifier_masking" 5 | let details = "Check if some identifiers are masked" 6 | let enabled = true 7 | end) 8 | 9 | type warning = 10 | | GlobalMasking 11 | 12 | let w_global_masking = Linter.new_warning 13 | ~id:1 14 | ~short_name:"global_masking" 15 | ~msg:"The identifier ... is masking a global identifier." 16 | ~severity:1 17 | 18 | module Warnings = Linter.MakeWarnings(struct 19 | type t = warning 20 | 21 | let to_warning = function 22 | | GlobalMasking -> 23 | w_global_masking, [] 24 | end) 25 | 26 | let iter = 27 | let module IterArg = struct 28 | include Typedtree_iter.DefaultIteratorArgument 29 | 30 | let enter_structure_item item = 31 | let open Typedtree in 32 | let open Asttypes in 33 | begin match item.str_desc with 34 | | Tstr_open desc -> 35 | Env.fold_values begin fun x y _ _ -> 36 | () 37 | end None item.str_env () 38 | | _ -> () 39 | end 40 | 41 | end in 42 | (module IterArg : Typedtree_iter.IteratorArgument) 43 | 44 | module MainML = Linter.MakeInputCMT(struct 45 | let main cmt = Typedtree_iter.iter_structure iter cmt 46 | end) 47 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/plugin_typedtree.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | let details = 22 | "A plugin with linters on typed tree" 23 | 24 | module Plugin = Lint_plugin_api.MakePlugin (struct 25 | let name = "Typedtree plugin" 26 | let short_name = "plugin_typedtree" 27 | let details = details 28 | let enabled = true 29 | end) 30 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/tests/.gitignore: -------------------------------------------------------------------------------- 1 | /test.current 2 | /_obuild 3 | /_olint 4 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/tests/.ocpstop: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/tests/Makefile: -------------------------------------------------------------------------------- 1 | 2 | PLUGIN=ocp-lint-plugin-parsing 3 | OBUILD=../../../_obuild 4 | LINT=$(OBUILD)/ocp-lint/ocp-lint.asm --load-plugins $(OBUILD)/$(PLUGIN)/$(PLUGIN).cmxs 5 | 6 | all: 7 | rm -rf _obuild _olint 8 | ocp-build init 9 | ocp-build ocp-lint-plugin-parsing-test 10 | $(LINT) --init 11 | $(LINT) --path . > test.current 2>&1 12 | diff test.reference test.current && echo TEST OK || echo TEST FAILED 13 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/tests/build.ocp: -------------------------------------------------------------------------------- 1 | begin test "test-ocp-lint-plugin-typedtree" 2 | files = [ ] 3 | 4 | test_byte = false 5 | requires = [ "ocp-lint-testsuite" ] 6 | test_args = [ 7 | "%{ocp-lint_FULL_DST_DIR}%/ocp-lint.asm" 8 | "%{sources}%" 9 | ] 10 | 11 | end 12 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/tests/test.ml: -------------------------------------------------------------------------------- 1 | 2 | let x = Pervasives.open_in 3 | -------------------------------------------------------------------------------- /plugins/ocp-lint-plugin-typedtree/tests/test.reference: -------------------------------------------------------------------------------- 1 | Loading plugin "Parsing Linter" 2 | No DB file found, using a fresh DB 3 | Scanning files in project "."... 4 | Found '6' file(s) 5 | Starting analyses... 6 | plugin_parsing.raw_syntax: parsing ./test.ml 7 | Printing results... 8 | -------------------------------------------------------------------------------- /scripts/pre-commit-lint: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | LINT=_obuild/ocp-lint/ocp-lint.asm 4 | 5 | $LINT --warn-error tools > /dev/null 6 | 7 | if [ "$?" = 0 ]; then 8 | exit 0 9 | else 10 | echo "\n/!\\ Please fix the warnings before commiting./!\\" 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /specs/Makefile: -------------------------------------------------------------------------------- 1 | NAME = typerex-lint 2 | DEPS = $(wildcard *.tex) 3 | 4 | all: *.tex 5 | rubber --pdf $(NAME) 6 | 7 | clean: 8 | -rm -f $(NAME).log $(NAME).toc $(NAME).blg $(NAME).bbl $(NAME).aux 9 | -rm -f *~ 10 | 11 | bib: $(NAME).bbl 12 | 13 | .phony: clean bib 14 | -------------------------------------------------------------------------------- /specs/biblio.bib: -------------------------------------------------------------------------------- 1 | 2 | @Misc{DeadCodeAnalyzer, 3 | author = {LexiFi}, 4 | title = {OCaml Dead Code Analyzer}, 5 | howpublished = {\url{https://github.com/LexiFi/dead code analyzer}}, 6 | year = {2015--2016} 7 | } 8 | 9 | @Misc{ocamllint, 10 | author = {Cryptosense}, 11 | title = {ocamllint}, 12 | howpublished = {\url{https://github.com/cryptosense/ocamllint}}, 13 | year = {2015--2016} 14 | } 15 | 16 | @Misc{mascot, 17 | author = {Xavier Clerc}, 18 | title = {Mascot}, 19 | howpublished = {\url{http://mascot.x9c.fr/}}, 20 | year = {2010--2012} 21 | } 22 | 23 | @Misc{coccinelle, 24 | author = {Julia Lawall, Laboratoire d'Informatique de Paris 6}, 25 | title = {coccinelle}, 26 | howpublished = {\url{http://coccinelle.lip6.fr/}}, 27 | year = {2009--2016} 28 | } 29 | 30 | @article{ppx, 31 | author = "Leo White", 32 | title = "Extensions points for OCaml", 33 | year = "2013", 34 | } 35 | 36 | @Misc{ppx-blog, 37 | author = {Yaron Minsky}, 38 | title = {"Extension Points, or how OCaml is becoming more like Lisp"}, 39 | howpublished = {\url{https://blogs.janestreet.com/extension-points-or-how-ocaml-is-becoming-more-like-lisp/}}, 40 | year = {2008} 41 | } 42 | 43 | @Misc{ocplib-config, 44 | author = {OCamlPro}, 45 | organization = {OCamlPro}, 46 | title = {ocplib-config}, 47 | howpublished = {\url{https://www.typerex.org/ocp-build.html}}, 48 | } 49 | 50 | @Misc{ocp-autoconf, 51 | author = {OCamlPro}, 52 | organization = {OCamlPro}, 53 | title = {ocp-autoconf}, 54 | howpublished = {\url{https://www.typerex.org/ocp-build.html}}, 55 | } 56 | -------------------------------------------------------------------------------- /specs/conclusion.tex: -------------------------------------------------------------------------------- 1 | When designing \ocplint{}, our goal was to use it on our own Github 2 | projects, to check pull-requests both from the project developers and 3 | from external contributors. We plan to apply it soon to all our 4 | projects, once most of the analyses we need are implemented. 5 | 6 | Although we currently use a non-optimized approach in the 7 | implementation of the analyses (different checks are often done in 8 | different analyses, while they could be done in the same iteration on 9 | the AST), performance is good enough for its purpose. For example, 10 | running \emph{sequentially} all the current 30 analysis of our 6 plugins, we 11 | get the following performances:\\ 12 | {\small\noindent 13 | \begin{tabular}{|l|l|l|l|l|} 14 | \hline 15 | Project & Files & LOC & Warnings & Time \\ 16 | \hline 17 | ocp-index & 12 & 4333 & 36 & 0.14s \\ 18 | \hline 19 | ocp-indent & 12 & 5763 & 44 & 0.32s \\ 20 | \hline 21 | stdlib & 35 & 12957 & 80 & 2.18s \\ 22 | \hline 23 | opam & 64 & 26906 & 362 & 3.09s \\ 24 | \hline 25 | flow & 119 & 47833 & 563 & 13.25s \\ 26 | \hline 27 | hack & 386 & 73715 & 1213 & 33.57s \\ 28 | \hline 29 | \end{tabular}}\\ 30 | 31 | We also took internationnalization into account in the design: the 32 | message associated with each warning is a simple string, that will be 33 | customized in the future for different languages. 34 | 35 | The project sources are hosted on Github, and an OPAM package should 36 | be available soon. 37 | -------------------------------------------------------------------------------- /specs/database.tex: -------------------------------------------------------------------------------- 1 | TODO {\bf cache system} -------------------------------------------------------------------------------- /specs/related.tex: -------------------------------------------------------------------------------- 1 | \ocplint{} is not the only tool that can be used to improve the quality of 2 | the code of an OCaml project. In this section, we compare \ocplint{} with 3 | three other tools that can be used for this purpose. 4 | 5 | {\em Mascot}~\cite{mascot} was probably the most exhaustive 6 | style-checker for OCaml. It provided many checks in various 7 | categories: code, documentation, interface, metrics, and 8 | typography. However, it is not maintained anymore, and hard to extend, 9 | especially as analyses are heavily based on using Camlp4 syntax trees. 10 | 11 | {\tt ocamllint}~\cite{ocamllint} is a style-checker that runs as {\sf 12 | ppx}~\cite{ppx-blog} while compiling the project. Thus, it 13 | requires minimum effort to be used on an OCaml project. However, the 14 | number of analyses is currently very limited, and they can only be 15 | applied on the AST, whereas \ocplint{} can work also on text files, 16 | and on typedtrees. 17 | 18 | {\em Dead code analyzer}~\cite{DeadCodeAnalyzer} tries to detect 19 | useless patterns in an OCaml project. For example, it detects never 20 | used values, types fields and constructors (that can thus be removed 21 | as dead code), and optional labels either always or never used. The 22 | tool assumes that interface files ({\tt .mli}) are compiled with the 23 | {\tt -keep-locs} and source files ({\tt .ml}) with {\tt 24 | -bin-annot}. The analysis can be quite expensive, but the tool is a 25 | good complement to \ocplint{}, and could be added as a plugin to 26 | benefit from its database and project management. 27 | -------------------------------------------------------------------------------- /specs/sempatch.tex: -------------------------------------------------------------------------------- 1 | The \texttt{ocplib-sempatch} library was inspired the Semantic Patches 2 | from by Coccinelle~\cite{coccinelle}. It provides a simple text DSL to 3 | describe patterns on OCaml syntax in a patch-like style, and these 4 | patterns can be used to locate these patterns in source files. For 5 | that, it uses a regular expression engine operating on the OCaml 6 | AST --- the parsing AST or, when needed and possible, the typed AST\@. 7 | 8 | In \ocplint{}, we use this library to allow the user to provide its 9 | own OCaml patterns to recognize. For example, the following patch will 10 | make \ocplint{} raise a warning, proposing to replace a {\sf 11 | if-then-else} constructs with identical expressions in both branches 12 | by a simple sequence, ignoring the result of the condition: 13 | 14 | \lstinputlisting[ 15 | columns=flexible, basicstyle=\sf\small 16 | ]{sempatch_example.sp} 17 | 18 | We were able to use these semantic patches to express most of the 19 | patterns recognized by {\sf ocamllint}. 20 | 21 | -------------------------------------------------------------------------------- /specs/sempatch_example.sp: -------------------------------------------------------------------------------- 1 | @ConstantIf 2 | expressions: cond, e1, e2 3 | when: ``e1 = e2'' 4 | ``` 5 | - if cond then e1 else e2 6 | + ignore (cond:bool); e1 7 | ``` 8 | -------------------------------------------------------------------------------- /specs/typerex-lint.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/specs/typerex-lint.pdf -------------------------------------------------------------------------------- /testsuite/README.md: -------------------------------------------------------------------------------- 1 | # Testsuite 2 | 3 | ## How to update the testsuite : 4 | 5 | If there is new plugins or linters, `testsuite/.ocplint` needs to be updated. 6 | It needs to have all plugins/linters activated. 7 | 8 | Once this is done, just run the script in `plugins/` : 9 | 10 | `sh make_db_test.sh` -------------------------------------------------------------------------------- /testsuite/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | 22 | begin program "ocp-lint-testsuite" 23 | files = [ 24 | "testsuite.ml" 25 | ] 26 | requires = [ "unix" "str" "ocp-lint-db" "ocp-lint-api" "ocp-lint-utils"] 27 | end 28 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/README.md: -------------------------------------------------------------------------------- 1 | # Ocp-lint-doc: Web page generator 2 | 3 | This tool will generate a web page listing the plugings with their linters 4 | and warnings. 5 | 6 | ## Dependencies 7 | 8 | Omd, tyxml 9 | 10 | ## Build Instructions 11 | 12 | $ make 13 | 14 | ## Running 15 | 16 | Use `_obuild/ocp-lint-doc/ocp-lint-doc.{asm,byte}` 17 | 18 | This will generate a index.html in tools/ocp-lint-doc -------------------------------------------------------------------------------- /tools/ocp-lint-doc/css/ocplint.css: -------------------------------------------------------------------------------- 1 | .sidebar-nav li a.sub-menu { 2 | padding-left:20px; 3 | } 4 | 5 | table { 6 | width: 100% 7 | } 8 | 9 | table tr { 10 | padding: 5px; 11 | } 12 | table th { 13 | padding: 5px; 14 | } 15 | table td { 16 | padding: 5px; 17 | } 18 | 19 | .searchtab tbody tr:hover{ 20 | background-color: #A9A9A9; 21 | } 22 | 23 | .warntab tbody tr:hover { 24 | background-color: #A9A9A9; 25 | } 26 | 27 | #search_box { 28 | background-image: url('searchicon.png'); 29 | background-position: 10px 12px; 30 | background-repeat: no-repeat; 31 | width: 100%; 32 | font-size: 16px; 33 | padding: 12px 20px 12px 40px; 34 | border: 1px solid #ddd; 35 | margin-bottom: 12px; 36 | } -------------------------------------------------------------------------------- /tools/ocp-lint-doc/css/searchicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/css/searchicon.png -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_complex.interface_module_type_name.1.ml: -------------------------------------------------------------------------------- 1 | module type modultype = sig end 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_complex.interface_module_type_name.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 0-31: 2 | Warning 1: plugin_complex/interface_module_type_name/interface_module_type_name_check SEVERITY 1 3 | Module type name 'modultype' should be uppercase as 'MODULTYPE'. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_file_system.interface_missing.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_file_system.interface_missing.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_file_system.interface_missing.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_file_system.interface_missing.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_file_system.project_files.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_file_system.project_files.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_file_system.project_files.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_file_system.project_files.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_file_system.project_files.2.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_file_system.project_files.2.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_file_system.project_files.2.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_file_system.project_files.2.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_indent.ocp_indent.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_indent.ocp_indent.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_indent.ocp_indent.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_indent.ocp_indent.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.check_constr_args.1.ml: -------------------------------------------------------------------------------- 1 | type t = A of (int * int) | B of int 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.check_constr_args.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 9-25: 2 | Warning 1: plugin_parsetree/check_constr_args/tuple-arg-with-paren SEVERITY 9 3 | Constructor "A" has a tuple argument instead of multiple arguments 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_identifier_length.1.ml: -------------------------------------------------------------------------------- 1 | let x = 1 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_identifier_length.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 4-5: 2 | Warning 1: plugin_parsetree/code_identifier_length/identifier_too_short SEVERITY 1 3 | x is too short: it should be at least of size '2'. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_identifier_length.2.ml: -------------------------------------------------------------------------------- 1 | let an_identifier_longer_than_30_char = 3 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_identifier_length.2.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 4-37: 2 | Warning 2: plugin_parsetree/code_identifier_length/identifier_too_long SEVERITY 1 3 | an_identifier_longer_than_30_char is too long: it should be at most of size '30'. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_list_on_singleton.1.ml: -------------------------------------------------------------------------------- 1 | List.map (fun a -> a + 1) [] 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_list_on_singleton.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 26-28: 2 | Warning 1: plugin_parsetree/code_list_on_singleton/list_function_on_empty SEVERITY 7 3 | List.map is used on an empty list. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_list_on_singleton.2.ml: -------------------------------------------------------------------------------- 1 | List.iter print_endline [ "singleton" ] 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_list_on_singleton.2.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 38-39: 2 | Warning 2: plugin_parsetree/code_list_on_singleton/list_function_on_singleton SEVERITY 7 3 | List.iter is used on a singleton. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_redefine_stdlib_module.1.ml: -------------------------------------------------------------------------------- 1 | module Pervasives = struct end 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_redefine_stdlib_module.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 7-17: 2 | Warning 1: plugin_parsetree/code_redefine_stdlib_module/redfine_stdlib_module SEVERITY 7 3 | Pervasives is a stdlib module and should not be masked. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_redefine_stdlib_module.2.ml: -------------------------------------------------------------------------------- 1 | module Location = struct end 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.code_redefine_stdlib_module.2.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 7-15: 2 | Warning 2: plugin_parsetree/code_redefine_stdlib_module/redfine_compilerlib_module SEVERITY 7 3 | Location is a compilerlib module and should not be masked. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.external_code.1.ml: -------------------------------------------------------------------------------- 1 | external add : int -> int = 2 | "add" 3 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.external_code.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 9-12: 2 | Warning 1: plugin_parsetree/external_code/external_value SEVERITY 1 3 | Value "add" is external defined. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.2.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.2.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.2.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_parsetree.fabrice_good_practices.2.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.pattern_guard.1.ml: -------------------------------------------------------------------------------- 1 | let f = function 2 | | x when x > 10 -> 2 3 | | _ -> 1 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.pattern_guard.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 2, characters 11-17: 2 | Warning 1: plugin_parsetree/pattern_guard/use_guard SEVERITY 1 3 | Avoid to use guard. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.phys_comp_allocated_lit.1.ml: -------------------------------------------------------------------------------- 1 | "String1" == "String2" 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.phys_comp_allocated_lit.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 0-8: 2 | Warning 1: plugin_parsetree/phys_comp_allocated_lit/phys_comp_allocated_lit_checks SEVERITY 10 3 | Physical comparison on 'Strings'. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.polymorphic_variants.1.ml: -------------------------------------------------------------------------------- 1 | let e = `A 0 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.polymorphic_variants.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 8-12: 2 | Warning 1 : plugin_parsetree/polymorphic_variants/polymorphics_variants_type SEVERITY 1 3 | Should not use polymorphics variants type. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.type_declaration.1.ml: -------------------------------------------------------------------------------- 1 | type t = String.t 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsetree.type_declaration.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 5-6: 2 | Warning 1: plugin_parsetree/type_declaration/alias_type SEVERITY 1 3 | t is just an alias. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.check_tuple.1.ml: -------------------------------------------------------------------------------- 1 | let p = (0, 0) 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.check_tuple.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 8-14: 2 | Warning 1: plugin_parsetree/check_tuple/use_record_rather_than_tuple SEVERITY 1 3 | Should use a record rather than a tuple. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.1.ml: -------------------------------------------------------------------------------- 1 | if (some_boolean) then 2 | expr 3 | else 4 | expr 5 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 3-17: 2 | Warning 1: plugin_parsing/raw_syntax/avoid_paren.if_argument SEVERITY 1 3 | Avoid parentheses around if argument -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.2.ml: -------------------------------------------------------------------------------- 1 | match foo with 2 | | None -> -1 3 | | Some i -> 4 | match i with 5 | | xxx -> 2 6 | | _ -> 3 7 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.2.warn: -------------------------------------------------------------------------------- 1 | File filename, line 4, characters 2-38: 2 | Warning 2: plugin_parsing/raw_syntax/direct-match-in-case SEVERITY 7 3 | match should be enclosed in parentheses -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.3.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | 0::[1 ; 2] 3 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.3.warn: -------------------------------------------------------------------------------- 1 | File filename, line 2, characters 2-12: 2 | Warning 3: plugin_parsing/raw_syntax/inconsistent-list-notations SEVERITY 1 3 | Inconsistent list notations -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.4.ml: -------------------------------------------------------------------------------- 1 | type a = A of (int) 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.4.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 9-19: 2 | Warning 4: plugin_parsing/raw_syntax/avoid_paren.constr_uniq_arg SEVERITY 1 3 | Avoid parentheses around constructor "A" uniq argument -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.5.ml: -------------------------------------------------------------------------------- 1 | let x = (1) 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.5.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 8-11: 2 | Warning 5: plugin_parsing/raw_syntax/avoid_paren.simple_expr SEVERITY 1 3 | Avoid parentheses around simple expression 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.6.ml: -------------------------------------------------------------------------------- 1 | let f x y = (x + y) 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.6.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 8-19: 2 | Warning 6: plugin_parsing/raw_syntax/avoid_paren.function_body SEVERITY 1 3 | Avoid parentheses around function body -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.7.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | if some_bool then 3 | (Printf.printf "..."; 4 | 1) 5 | else 6 | 2 7 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.7.warn: -------------------------------------------------------------------------------- 1 | File filename, line 3, characters 4-33: 2 | Warning 7: plugin_parsing/raw_syntax/paren_block.then SEVERITY 1 3 | Good practice: use '..then begin..end' instead of '..then (..)' -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.8.ml: -------------------------------------------------------------------------------- 1 | let _ = 2 | if some_bool then 3 | 1 4 | else 5 | (Printf.printf "..."; 6 | 2) 7 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_parsing.raw_syntax.8.warn: -------------------------------------------------------------------------------- 1 | File filename, line 5, characters 4-33: 2 | Warning 8: plugin_parsing/raw_syntax/paren_block.else SEVERITY 1 3 | Good practice: use '..else begin..end' instead of '..else (..)' -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.code_length.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.code_length.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.code_length.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.code_length.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.not_that_char.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.not_that_char.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.not_that_char.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.not_that_char.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.not_that_char.2.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.not_that_char.2.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.not_that_char.2.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.not_that_char.2.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.useless_space_line.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.useless_space_line.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.useless_space_line.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.useless_space_line.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.useless_space_line.2.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.useless_space_line.2.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_text.useless_space_line.2.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_text.useless_space_line.2.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_hash_table.1.ml: -------------------------------------------------------------------------------- 1 | Hashtbl.create 10 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_hash_table.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 0-14: 2 | Warning 1: plugin_typedtree/check_hash_table/randomization_disable SEVERITY 1 3 | Hash tables should be randomized. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.1.ml: -------------------------------------------------------------------------------- 1 | let b = Bytes.unsafe_of_string "" 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 8-30: 2 | Warning 1: plugin_typedtree/function_call/unsafe_function SEVERITY 1 3 | Bytes.unsafe_of_string is an unsafe function -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.2.ml: -------------------------------------------------------------------------------- 1 | Dynlink.loadfile "f.ml" 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.2.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 0-16: 2 | Warning 2: plugin_typedtree/function_call/dynamic_linking_function SEVERITY 1 3 | Dynlink.loadfile is a dynamic linking function. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.3.ml: -------------------------------------------------------------------------------- 1 | let s = String.create 10 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.3.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 8-21: 2 | Warning 3: plugin_typedtree/function_call/deprecated_function SEVERITY 1 3 | String.create is a deprecated function, use String.make. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.4.ml: -------------------------------------------------------------------------------- 1 | Pervasives.at_exit (fun () -> print_string "end") 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.check_identifier.4.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 0-18: 2 | Warning 4: plugin_typedtree/function_call/environment_modification_function SEVERITY 1 3 | Pervasives.at_exit modifies the global execution environment. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.fully_qualified_identifiers.1.ml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_typedtree.fully_qualified_identifiers.1.ml -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.fully_qualified_identifiers.1.warn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/examples/plugin_typedtree.fully_qualified_identifiers.1.warn -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.module_utilization.1.ml: -------------------------------------------------------------------------------- 1 | let obj = Obj.repr "" 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.module_utilization.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 10-18: 2 | Warning 1: plugin_typedtree/module_utilization/identifier_from_unrecommanded_module SEVERITY 1 3 | Identifier "repr" is in the unrecommanded module Obj. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.module_utilization.2.ml: -------------------------------------------------------------------------------- 1 | open String 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.module_utilization.2.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 0-11: 2 | Warning 2: plugin_typedtree/module_utilization/use_open_directive SEVERITY 1 3 | Avoid to use the open directive. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.module_utilization.3.ml: -------------------------------------------------------------------------------- 1 | Random.init 0 2 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.module_utilization.3.warn: -------------------------------------------------------------------------------- 1 | File filename, line 1, characters 0-11: 2 | Warning 3: plugin_typedtree/module_utilization/environment_modification_module SEVERITY 1 3 | Random modifies the global execution environment. -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.polymorphic_function.1.ml: -------------------------------------------------------------------------------- 1 | type t = A of int 2 | 3 | let _ = 4 | (A 3) = (A 4) 5 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/examples/plugin_typedtree.polymorphic_function.1.warn: -------------------------------------------------------------------------------- 1 | File filename, line 4, characters 8-9: 2 | Warning 1: plugin_typedtree/polymorphic_function/poly SEVERITY 10 3 | Polymorphic function: 'Pervasives.=' is used with 't -> t -> bool'. 4 | -------------------------------------------------------------------------------- /tools/ocp-lint-doc/ocp.stop: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-doc/ocp.stop -------------------------------------------------------------------------------- /tools/ocp-lint-web/doc/img/ocp_lint_web_errors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/doc/img/ocp_lint_web_errors.png -------------------------------------------------------------------------------- /tools/ocp-lint-web/doc/img/ocp_lint_web_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/doc/img/ocp_lint_web_file.png -------------------------------------------------------------------------------- /tools/ocp-lint-web/doc/img/ocp_lint_web_file_errors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/doc/img/ocp_lint_web_file_errors.png -------------------------------------------------------------------------------- /tools/ocp-lint-web/doc/img/ocp_lint_web_file_warnings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/doc/img/ocp_lint_web_file_warnings.png -------------------------------------------------------------------------------- /tools/ocp-lint-web/doc/img/ocp_lint_web_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/doc/img/ocp_lint_web_home.png -------------------------------------------------------------------------------- /tools/ocp-lint-web/doc/img/ocp_lint_web_warnings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/doc/img/ocp_lint_web_warnings.png -------------------------------------------------------------------------------- /tools/ocp-lint-web/doc/makefile: -------------------------------------------------------------------------------- 1 | TEX = pdflatex -shell-escape -interaction=nonstopmode -file-line-error 2 | 3 | all : ocp-lint-web.pdf 4 | 5 | view : 6 | open ocp-lint-web.pdf 7 | 8 | ocp-lint-web.pdf : 9 | $(TEX) ocp-lint-web.tex 10 | 11 | clean: 12 | rm -f *.log 13 | rm -f *.aux 14 | rm -f *.out 15 | rm -f *.toc 16 | rm -f *.pdf 17 | -------------------------------------------------------------------------------- /tools/ocp-lint-web/src/web_errors_content.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | (** 22 | Create the errors content page 23 | **) 24 | val content : 25 | Web_navigation_system.t -> 26 | Lint_web_analysis_info.analysis_info -> 27 | Html_types.div Tyxml_js.Html.elt 28 | -------------------------------------------------------------------------------- /tools/ocp-lint-web/src/web_home_content.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | (** 22 | Create the home content page 23 | **) 24 | val content : 25 | Web_navigation_system.t -> 26 | Lint_web_analysis_info.analysis_info -> 27 | Html_types.div Tyxml_js.Html.elt 28 | -------------------------------------------------------------------------------- /tools/ocp-lint-web/src/web_warnings_content.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | (** 22 | Create the warnings content page 23 | **) 24 | val content : 25 | Web_navigation_system.t -> 26 | Lint_web_analysis_info.analysis_info -> 27 | Html_types.div Tyxml_js.Html.elt 28 | -------------------------------------------------------------------------------- /tools/ocp-lint-web/static/css/adjustment_ace.css: -------------------------------------------------------------------------------- 1 | .ace_editor { 2 | position: absolute !important; 3 | top: 0 !important; 4 | right: 0 !important; 5 | bottom: 0 !important; 6 | left: 0 !important; 7 | } 8 | 9 | .ace_cursor { 10 | display: none !important; 11 | } 12 | 13 | /* .warning { */ 14 | /* position:absolute; */ 15 | /* background:green; */ 16 | /* z-index:20 */ 17 | /* } */ 18 | 19 | .warning { 20 | position:absolute; /* require for ace */ 21 | /* z-index:20; */ 22 | 23 | background-image: 24 | linear-gradient(45deg, transparent 65%, yellow 80%, transparent 90%), 25 | linear-gradient(135deg, transparent 5%, yellow 15%, transparent 25%), 26 | linear-gradient(135deg, transparent 45%, yellow 55%, transparent 65%), 27 | linear-gradient(45deg, transparent 25%, yellow 35%, transparent 50%); 28 | background-repeat:repeat-x; 29 | background-size: 8px 2px; 30 | background-position:0 95%; 31 | padding-top:2px 32 | } -------------------------------------------------------------------------------- /tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OCamlPro/typerex-lint/6d9e994c8278fb65e1f7de91d74876531691120c/tools/ocp-lint-web/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /tools/ocp-lint-web/static/js/ocplib_re.js: -------------------------------------------------------------------------------- 1 | //Provides: re_search_forward 2 | function re_search_forward () { return 1; } 3 | -------------------------------------------------------------------------------- /tools/ocp-lint-web/static/js/ocplib_unix.js: -------------------------------------------------------------------------------- 1 | //Provides: minUnix_cleanup 2 | function minUnix_cleanup () { return 1; } 3 | 4 | //Provides: minUnix_filedescr_of_fd 5 | function minUnix_filedescr_of_fd () { return 1; } 6 | 7 | //Provides: minUnix_startup 8 | function minUnix_startup () { return 1; } // Bad_term 9 | -------------------------------------------------------------------------------- /tools/ocp-lint/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains the sources of `ocp-lint`: 2 | 3 | * `utils/`: useful functions not specific to ocp-lint 4 | * `config/`: management of configuration files 5 | * `init/`: initial modules (global variables) 6 | * `db/`: persistent database of warnings 7 | * `api/`: types and modules used by lint plugins 8 | * `output/`: printing of warnings 9 | * `main/`: main modules 10 | 11 | Documentation should be available in the `DOCS` directory. 12 | 13 | -------------------------------------------------------------------------------- /tools/ocp-lint/api/lint_map.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | module LintMap = Map.Make (String) 22 | 23 | include LintMap 24 | -------------------------------------------------------------------------------- /tools/ocp-lint/api/lint_map.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | (** [LintMap] is a Map containing all information about the linter. 22 | The key is a [string] representing the linter name, and the value of the 23 | map contains a list of [input] (registered mains). *) 24 | type 'a t 25 | val empty : 'a t 26 | val add : string -> 'a -> 'a t -> 'a t 27 | val iter : (string -> 'a -> unit) -> 'a t -> unit 28 | val find : string -> 'a t -> 'a 29 | val cardinal : 'a t -> int 30 | val fold : (string -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b 31 | -------------------------------------------------------------------------------- /tools/ocp-lint/api/lint_plugin_types.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | module type PLUGINARG = sig 22 | val name : string 23 | val short_name : string 24 | val details : string 25 | val enabled : bool 26 | end 27 | 28 | module type PLUGIN = sig 29 | val name : string 30 | val short_name : string 31 | val details : string 32 | val enabled : bool 33 | end 34 | -------------------------------------------------------------------------------- /tools/ocp-lint/api/lint_plugin_types.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | module type PLUGINARG = sig 22 | val name : string 23 | val short_name : string 24 | val details : string 25 | val enabled : bool 26 | end 27 | 28 | module type PLUGIN = sig 29 | val name : string 30 | val short_name : string 31 | val details : string 32 | val enabled : bool 33 | end 34 | -------------------------------------------------------------------------------- /tools/ocp-lint/config/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-config" 22 | files = [ 23 | "lint_config_types.ml" 24 | "lint_config.ml" 25 | ] 26 | requires = [ 27 | "ocplib-config" 28 | ] 29 | end 30 | -------------------------------------------------------------------------------- /tools/ocp-lint/config/lint_config.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | module DefaultConfig : Lint_config_types.CONFIG 22 | -------------------------------------------------------------------------------- /tools/ocp-lint/db/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-db" 22 | files = [ 23 | "lint_db_types.ml" 24 | "lint_db_error.ml" 25 | "lint_db.ml" 26 | ] 27 | requires = [ 28 | "ocplib-system" 29 | "ocp-lint-api-types" 30 | "ocp-lint-config" 31 | ] 32 | end 33 | -------------------------------------------------------------------------------- /tools/ocp-lint/db/lint_db.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | open Lint_db_types 22 | 23 | module DefaultDB : DATABASE 24 | -------------------------------------------------------------------------------- /tools/ocp-lint/db/lint_db_error.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | type error = 22 | | File_not_found of string 23 | | File_not_in_db of string 24 | | Plugin_not_in_db of string * string 25 | | Linter_not_in_db of string * string * string 26 | | No_db_found 27 | 28 | exception Db_error of error 29 | 30 | val to_string : error -> string 31 | val print : Format.formatter -> error -> unit 32 | -------------------------------------------------------------------------------- /tools/ocp-lint/init/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | 22 | begin library "ocp-lint-init" 23 | files = [ 24 | "lint_globals.ml" 25 | ] 26 | requires = [ 27 | "ocp-lint-config" 28 | "ocp-lint-api-types" 29 | ] 30 | end 31 | -------------------------------------------------------------------------------- /tools/ocp-lint/init/lint_globals.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | module LintConfig = Lint_config.DefaultConfig 22 | 23 | let plugins = Hashtbl.create 42 24 | 25 | let olint_dirname = "_olint" 26 | -------------------------------------------------------------------------------- /tools/ocp-lint/main/lint.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | val main : unit -> unit 22 | -------------------------------------------------------------------------------- /tools/ocp-lint/main/lint_init_dynload.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | val init : unit -> unit 22 | -------------------------------------------------------------------------------- /tools/ocp-lint/main/lint_parallel_engine.ml: -------------------------------------------------------------------------------- 1 | type proc_status = Waiting | Running of int | Done 2 | 3 | let jobs_pool = Hashtbl.create 100 4 | 5 | let remaining_files = ref 0 6 | 7 | let find_next_waiting () = 8 | let elt = 9 | Hashtbl.fold (fun k v file -> 10 | if file <> None then 11 | file 12 | else 13 | match v with 14 | | Waiting -> Some k 15 | | _ -> file 16 | ) jobs_pool None in 17 | match elt with 18 | | None -> raise Not_found 19 | | Some file -> file 20 | 21 | let waiting_file () = !remaining_files > 0 22 | 23 | let done_files total_files = 24 | total_files - !remaining_files 25 | 26 | let mark_waiting sources = 27 | List.iter (fun file -> Hashtbl.add jobs_pool file Waiting) sources; 28 | let len = List.length sources in 29 | remaining_files := len 30 | 31 | let mark_running file pid = 32 | Hashtbl.replace jobs_pool file (Running pid) 33 | 34 | let mark_done pid = 35 | let elt = Hashtbl.fold (fun k v file -> 36 | if file <> None then 37 | file 38 | else 39 | match v with 40 | | Running i when i = pid -> Some k 41 | | _ -> file 42 | ) jobs_pool None in 43 | match elt with 44 | | None -> () 45 | | Some file -> 46 | Hashtbl.replace jobs_pool file Done; 47 | decr remaining_files 48 | 49 | let get_start_list jobs = 50 | let rec loop cpt acc = function 51 | | [] -> acc 52 | | hd :: tl -> 53 | if cpt = jobs then 54 | acc 55 | else loop (cpt + 1) (hd :: acc) tl 56 | in loop 0 [] 57 | -------------------------------------------------------------------------------- /tools/ocp-lint/main/lint_parallel_engine.mli: -------------------------------------------------------------------------------- 1 | type proc_status = Waiting | Running of int | Done 2 | 3 | val waiting_file : unit -> bool 4 | 5 | val done_files : int -> int 6 | 7 | val find_next_waiting : unit -> string 8 | 9 | val mark_waiting : string list -> unit 10 | 11 | val mark_running : string -> int -> unit 12 | 13 | val mark_done : int -> unit 14 | 15 | val get_start_list : int -> string list -> string list 16 | -------------------------------------------------------------------------------- /tools/ocp-lint/main/main.ml: -------------------------------------------------------------------------------- 1 | 2 | let () = Lint.main () 3 | -------------------------------------------------------------------------------- /tools/ocp-lint/utils/build.ocp: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | begin library "ocp-lint-utils" 22 | files = [ 23 | "lint_utils.ml" 24 | "lint_parse_args.ml" 25 | ] 26 | requires = [ 27 | "str" 28 | "ocplib-system" 29 | "compiler-libs.common" 30 | ] 31 | end 32 | -------------------------------------------------------------------------------- /tools/ocp-lint/utils/lint_parse_args.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* OCamlPro Typerex *) 4 | (* *) 5 | (* Copyright OCamlPro 2011-2016. All rights reserved. *) 6 | (* This file is distributed under the terms of the GPL v3.0 *) 7 | (* (GNU General Public Licence version 3.0). *) 8 | (* *) 9 | (* Contact: (http://www.ocamlpro.com/) *) 10 | (* *) 11 | (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *) 12 | (* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *) 13 | (* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *) 14 | (* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS *) 15 | (* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN *) 16 | (* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN *) 17 | (* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE *) 18 | (* SOFTWARE. *) 19 | (**************************************************************************) 20 | 21 | (** [parse_options filters] parse the arguments given in the command line 22 | or found in the config file to enable/disable warnings in a specific 23 | linter. It returns a [bool array], each position in the array correspond 24 | to a warning number. 25 | The returned array is not allocated, but shared between all the calls 26 | to the function. Its current size is 512. 27 | *) 28 | val parse_options : string -> bool array 29 | --------------------------------------------------------------------------------