diff --git a/src/plugins/markdown-report/eva_coverage.ml b/src/plugins/markdown-report/eva_coverage.ml index acd96c0940f1166958aa90d1b8a96ccbfd2cd1d3..7faa651c5da9d5a1f82e8e8ea83cd7154a397a3d 100644 --- a/src/plugins/markdown-report/eva_coverage.ml +++ b/src/plugins/markdown-report/eva_coverage.ml @@ -128,8 +128,8 @@ class eva_coverage_vis ~from_entry_point = object(self) if not from_entry_point then begin Globals.Functions.iter_on_fundecs (fun { svar } -> - Cil_datatype.Varinfo.Hashtbl.add - calls svar (is_analyzed_info svar no_call)) + Cil_datatype.Varinfo.Hashtbl.add + calls svar (is_analyzed_info svar no_call)) end; let vi = Globals.Functions.get_vi @@ -171,10 +171,10 @@ let md_gen () = Markdown.plain_format "There are %d function definitions that are not stubbed. They represent \ %d statements, of which %d are potentially reachable through EVA, \ - resulting in a **statement coverage of %.1f%%** with respect to the \ - entire application." + resulting in a **statement coverage of %.1f%%** with respect to the \ + entire application." (nb_fundefs()) - stats.total_stmts stats.covered_stmts + stats.total_stmts stats.covered_stmts (float_of_int stats.covered_stmts *. 100. /. float_of_int stats.total_stmts) in diff --git a/src/plugins/markdown-report/md_gen.ml b/src/plugins/markdown-report/md_gen.ml index b3d015cda0c6cfd6e531e537b34a2660c7ce81c2..0a6970b40931e1e186b6c7245a29655e8800ab28 100644 --- a/src/plugins/markdown-report/md_gen.ml +++ b/src/plugins/markdown-report/md_gen.ml @@ -37,7 +37,7 @@ let all_eva_domains = "-eva-symbolic-locations-domain", "domain computing ranges of variation for symbolic locations \ (e.g. `a[i]` when `i` is not precisely known by `Cvalue`)" -] + ] let insert_marks env anchor = Comment "BEGIN_REMARK" @@ -66,19 +66,19 @@ let section_domains env = let l = get_eva_domains () in head :: Block - (match l with - | [] -> - [Text - (plain - "Only the base domain (`Cvalue`) \ - has been used for the analysis")] - | _ -> - [Text - (plain - "In addition to the base domain (`Cvalue`), additional \ - domains have been used by EVA"); - DL l] - ) + (match l with + | [] -> + [Text + (plain + "Only the base domain (`Cvalue`) \ + has been used for the analysis")] + | _ -> + [Text + (plain + "In addition to the base domain (`Cvalue`), additional \ + domains have been used by EVA"); + DL l] + ) :: insert_remark env anchor end @@ -130,14 +130,14 @@ let section_stubs env = if env.is_draft then insert_marks env anchor else (Block - [ Text - (Inline_code name :: - plain_format - "@[<h>is defined at %a@]" Cil_datatype.Location.pretty loc); - codelines "c" - Printer.pp_global - (GFun (Kernel_function.get_definition kf,loc)) - ]) + [ Text + (Inline_code name :: + plain_format + "@[<h>is defined at %a@]" Cil_datatype.Location.pretty loc); + codelines "c" + Printer.pp_global + (GFun (Kernel_function.get_definition kf,loc)) + ]) :: insert_remark env anchor in H4 ([Inline_code name], Some anchor) :: content @@ -213,8 +213,8 @@ let gen_inputs env = "You can add here some remarks about the set of files \ that is considered by Frama-C" :: insert_marks env anchor - else - insert_remark env anchor + else + insert_remark env anchor in H2 (plain "Input files", Some anchor) :: prelude @@ -268,11 +268,11 @@ let gen_context env = @ section_domains env @ H3 (plain "Stubbed Functions", Some "stubs") :: ( - if env.is_draft then - Comment - "You can add here general comments about the stubs that have been used" - :: insert_marks env "stubs" - else insert_remark env "stubs") + if env.is_draft then + Comment + "You can add here general comments about the stubs that have been used" + :: insert_marks env "stubs" + else insert_remark env "stubs") @ section_stubs env let gen_coverage env = @@ -471,7 +471,7 @@ let gen_section_alarms env = in (i+1, sec @ H2 (sec_title, Some label) :: sec_content, - [ link; kind; emitter; func; loc_text ] :: content) + [ link; kind; emitter; func; loc_text ] :: content) in let _,sections, content = Alarms.fold treat_alarm (0,[],[]) in let content = List.rev content in @@ -490,7 +490,7 @@ let gen_section_alarms env = Plain "in a context matching the one used for the analysis"; Plain "will be immune from any undefined behavior." ] - ] + ] :: insert_remark env anchor in H1 (plain "Results of the analysis", Some anchor) :: text_content @@ -618,9 +618,9 @@ let gen_report ~draft:is_draft () = else elements in let elements = - Raw [ "\\let\\underscore\\_" ; - "\\renewcommand{\\_}{\\discretionary{\\underscore}{}{\\underscore}}"] - :: elements + Raw [ "\\let\\underscore\\_" ; + "\\renewcommand{\\_}{\\discretionary{\\underscore}{}{\\underscore}}"] + :: elements in let doc = Markdown.pandoc ~title ~authors elements in try diff --git a/src/plugins/markdown-report/mdr_params.ml b/src/plugins/markdown-report/mdr_params.ml index be8ef4d1c14c119e9de9be2612e0a9140571c96c..2b08c1783d0f6f65f250ac265ea59e2f964224d5 100644 --- a/src/plugins/markdown-report/mdr_params.ml +++ b/src/plugins/markdown-report/mdr_params.ml @@ -6,63 +6,63 @@ include Plugin.Register( end) module Output = String( -struct - let option_name = "-mdr-out" - let arg_name = "f" - let default = "report.md" - let help = "sets the name of the output file to <f>" -end) + struct + let option_name = "-mdr-out" + let arg_name = "f" + let default = "report.md" + let help = "sets the name of the output file to <f>" + end) module Generate = String( -struct - let option_name = "-mdr-gen" - let arg_name = "kind" - let default = "none" - let help = - "select the <kind> of report to generate among: \ - none (default), md, draft and sarif" -end) + struct + let option_name = "-mdr-gen" + let arg_name = "kind" + let default = "none" + let help = + "select the <kind> of report to generate among: \ + none (default), md, draft and sarif" + end) let () = Generate.set_possible_values [ "none"; "md"; "draft"; "sarif" ] module Remarks = Empty_string( -struct - let option_name = "-mdr-remarks" - let arg_name = "f" - let help = - "reads file <f> to add additional remarks to various sections of the report. \ - Must be in a format compatible with the file produced by -mdr-gen-draft. \ - Remarks themselves must be written in pandoc's markdown, although this is \ - not enforced by the plug-in" -end -) + struct + let option_name = "-mdr-remarks" + let arg_name = "f" + let help = + "reads file <f> to add additional remarks to various sections of the report. \ + Must be in a format compatible with the file produced by -mdr-gen-draft. \ + Remarks themselves must be written in pandoc's markdown, although this is \ + not enforced by the plug-in" + end + ) module FlameGraph = Empty_string( -struct - let option_name = "-mdr-flamegraph" - let arg_name = "f" - let help = - "reads file <f> to include a FlameGraph (https://github.com/brendangregg/FlameGraph.git),\ - allowing the most analysis-intensive callstacks to be identified\ - quickly and accurately" -end -) + struct + let option_name = "-mdr-flamegraph" + let arg_name = "f" + let help = + "reads file <f> to include a FlameGraph (https://github.com/brendangregg/FlameGraph.git),\ + allowing the most analysis-intensive callstacks to be identified\ + quickly and accurately" + end + ) module Authors = String_list( -struct - let option_name = "-mdr-authors" - let arg_name = "l" - let help = "list of authors of the report" -end) + struct + let option_name = "-mdr-authors" + let arg_name = "l" + let help = "list of authors of the report" + end) module Title = Empty_string( -struct - let option_name = "-mdr-title" - let arg_name = "t" - let help = "title of the generated document" -end -) + struct + let option_name = "-mdr-title" + let arg_name = "t" + let help = "title of the generated document" + end + ) module Stubs = String_list( struct diff --git a/src/plugins/markdown-report/sarif.ml b/src/plugins/markdown-report/sarif.ml index 7bc383a632f26e91c779a1ea00813fc31bdd3e36..cdc0b9f85d7d80c5219ab133d84170bcf7565385 100644 --- a/src/plugins/markdown-report/sarif.ml +++ b/src/plugins/markdown-report/sarif.ml @@ -63,26 +63,26 @@ module Message = struct arguments: (string list [@default []]); }[@@deriving yojson] -let create - ?(text="") - ?(messageId="") - ?(richText="") - ?(richMessageId="") - ?(arguments=[]) - () - = - { text; messageId; richText; richMessageId; arguments } + let create + ?(text="") + ?(messageId="") + ?(richText="") + ?(richMessageId="") + ?(arguments=[]) + () + = + { text; messageId; richText; richMessageId; arguments } -let plain_text ~text ?id:messageId ?arguments () = - create ~text ?messageId ?arguments () + let plain_text ~text ?id:messageId ?arguments () = + create ~text ?messageId ?arguments () -let markdown ~markdown ?id:richMessageId ?arguments () = - let richText = - String.trim (Format.asprintf "@[%a@]" Markdown.pp_elements markdown) - in - create ~richText ?richMessageId ?arguments () + let markdown ~markdown ?id:richMessageId ?arguments () = + let richText = + String.trim (Format.asprintf "@[%a@]" Markdown.pp_elements markdown) + in + create ~richText ?richMessageId ?arguments () -let default = create () + let default = create () end module FileLocation = struct @@ -103,55 +103,55 @@ module FileLocation = struct end module FileContent = struct -type t = - | Text of string [@name "text"] - | Binary of string [@name "binary"] -[@@deriving yojson] + type t = + | Text of string [@name "text"] + | Binary of string [@name "binary"] + [@@deriving yojson] -let default = Text "" + let default = Text "" end module Region = struct -type t = { - startLine: (int [@default 0]); - startColumn: (int [@default 0]); - endLine: (int [@default 0]); - endColumn: (int [@default 0]); - charOffset: (int [@default 0]); - charLength: (int [@default 0]); - byteOffset: (int [@default 0]); - byteLength: (int [@default 0]); - snippet: (FileContent.t [@default FileContent.default]); - message: (Message.t [@default Message.default]) -}[@@deriving yojson] - -let create - ?(startLine = 0) - ?(startColumn = 0) - ?(endLine = 0) - ?(endColumn = 0) - ?(charOffset = 0) - ?(charLength = 0) - ?(byteOffset = 0) - ?(byteLength = 0) - ?(snippet = FileContent.default) - ?(message = Message.default) - () - = - { startLine; startColumn; endLine; endColumn; charOffset; charLength; - byteOffset; byteLength; snippet; message } - -let default = create () - -let of_loc loc = - let open Filepath in - let (start, finish) = loc in - let startLine = start.pos_lnum in - let startColumn = start.pos_cnum - start.pos_bol in - let endLine = finish.pos_lnum in - let endColumn = finish.pos_cnum - finish.pos_bol in - let byteLength = finish.pos_cnum - start.pos_cnum in - create ~startLine ~startColumn ~endLine ~endColumn ~byteLength () + type t = { + startLine: (int [@default 0]); + startColumn: (int [@default 0]); + endLine: (int [@default 0]); + endColumn: (int [@default 0]); + charOffset: (int [@default 0]); + charLength: (int [@default 0]); + byteOffset: (int [@default 0]); + byteLength: (int [@default 0]); + snippet: (FileContent.t [@default FileContent.default]); + message: (Message.t [@default Message.default]) + }[@@deriving yojson] + + let create + ?(startLine = 0) + ?(startColumn = 0) + ?(endLine = 0) + ?(endColumn = 0) + ?(charOffset = 0) + ?(charLength = 0) + ?(byteOffset = 0) + ?(byteLength = 0) + ?(snippet = FileContent.default) + ?(message = Message.default) + () + = + { startLine; startColumn; endLine; endColumn; charOffset; charLength; + byteOffset; byteLength; snippet; message } + + let default = create () + + let of_loc loc = + let open Filepath in + let (start, finish) = loc in + let startLine = start.pos_lnum in + let startColumn = start.pos_cnum - start.pos_bol in + let endLine = finish.pos_lnum in + let endColumn = finish.pos_cnum - finish.pos_bol in + let byteLength = finish.pos_cnum - start.pos_cnum in + create ~startLine ~startColumn ~endLine ~endColumn ~byteLength () end module Rectangle = struct @@ -161,8 +161,8 @@ module Rectangle = struct bottom: (float [@default 0.]); right: (float [@default 0.]); message: (Message.t [@default Message.default]); -} -[@@deriving yojson] + } + [@@deriving yojson] end module Custom_properties = @@ -214,11 +214,11 @@ module PhysicalLocation = struct }[@@deriving yojson] let create - ?(id = "") - ~fileLocation - ?(region = Region.default) - ?(contextRegion = Region.default) - () + ?(id = "") + ~fileLocation + ?(region = Region.default) + ?(contextRegion = Region.default) + () = { id; fileLocation; region; contextRegion } @@ -241,12 +241,12 @@ module Location = struct }[@@deriving yojson] let create - ~physicalLocation - ?(fullyQualifiedLogicalName = "") - ?(message = Message.default) - ?(annotations = []) - ?(properties = Properties.default) - () + ~physicalLocation + ?(fullyQualifiedLogicalName = "") + ?(message = Message.default) + ?(annotations = []) + ?(properties = Properties.default) + () = { physicalLocation; fullyQualifiedLogicalName; message; annotations; properties; @@ -349,20 +349,20 @@ module CodeFlow = struct end module Sarif_exception = struct -type t = { - kind: (string [@default ""]); - message: (string [@default ""]); - stack: (Stack.t [@default Stack.default]); - innerExceptions: (t list [@default []]); -}[@@deriving yojson] - -let default = - { - kind = ""; - message = ""; - stack = Stack.default; - innerExceptions = [] - } + type t = { + kind: (string [@default ""]); + message: (string [@default ""]); + stack: (Stack.t [@default Stack.default]); + innerExceptions: (t list [@default []]); + }[@@deriving yojson] + + let default = + { + kind = ""; + message = ""; + stack = Stack.default; + innerExceptions = [] + } end module Notification_kind: sig @@ -428,7 +428,7 @@ end module Invocation = struct -type t = { + type t = { commandLine: string; arguments: string list; responseFiles: (FileLocation.t list [@default []]); @@ -458,32 +458,32 @@ type t = { }[@@deriving yojson] let create - ~commandLine - ?(arguments = []) - ?(responseFiles = []) - ?(attachments = []) - ?(startTime = "") - ?(endTime = "") - ?(exitCode = 0) - ?(toolNotifications = []) - ?(configurationNotifications = []) - ?(exitCodeDescription = "") - ?(exitSignalName = "") - ?(exitSignalNumber = 0) - ?(processStartFailureMessage = "") - ?(toolExecutionSuccessful = true) - ?(machine = "") - ?(account = "") - ?(processId = 0) - ?(executableLocation = FileLocation.default) - ?(workingDirectory = FileLocation.default) - ?(environmentVariables = Additional_properties.default) - ?(stdin = FileLocation.default) - ?(stdout = FileLocation.default) - ?(stderr = FileLocation.default) - ?(stdoutStderr = FileLocation.default) - ?(properties = Properties.default) - () + ~commandLine + ?(arguments = []) + ?(responseFiles = []) + ?(attachments = []) + ?(startTime = "") + ?(endTime = "") + ?(exitCode = 0) + ?(toolNotifications = []) + ?(configurationNotifications = []) + ?(exitCodeDescription = "") + ?(exitSignalName = "") + ?(exitSignalNumber = 0) + ?(processStartFailureMessage = "") + ?(toolExecutionSuccessful = true) + ?(machine = "") + ?(account = "") + ?(processId = 0) + ?(executableLocation = FileLocation.default) + ?(workingDirectory = FileLocation.default) + ?(environmentVariables = Additional_properties.default) + ?(stdin = FileLocation.default) + ?(stdout = FileLocation.default) + ?(stderr = FileLocation.default) + ?(stdoutStderr = FileLocation.default) + ?(properties = Properties.default) + () = { commandLine; @@ -648,18 +648,18 @@ module File = struct }[@@deriving yojson] let create - ?(fileLocation = FileLocation.default) - ?(parentKey = "") - ?(offset = 0) - ?(length = 0) - ?(roles = []) - ?(mimeType = "") - ?(contents = FileContent.default) - ?(encoding = "") - ?(hashes = []) - ?(lastModifiedTime = "") - ?(properties = Properties.default) - () + ?(fileLocation = FileLocation.default) + ?(parentKey = "") + ?(offset = 0) + ?(length = 0) + ?(roles = []) + ?(mimeType = "") + ?(contents = FileContent.default) + ?(encoding = "") + ?(hashes = []) + ?(lastModifiedTime = "") + ?(properties = Properties.default) + () = { fileLocation; parentKey; offset; length; roles; mimeType; contents; @@ -762,16 +762,16 @@ module Rule = struct } let create - ~id - ?(name="") - ?(shortDescription=Message.default) - ?(fullDescription=Message.default) - ?(messageStrings=Additional_properties.default) - ?(richMessageStrings=Additional_properties.default) - ?(configuration=RuleConfiguration.default) - ?(helpUri="") - ?(properties=Properties.default) - () + ~id + ?(name="") + ?(shortDescription=Message.default) + ?(fullDescription=Message.default) + ?(messageStrings=Additional_properties.default) + ?(richMessageStrings=Additional_properties.default) + ?(configuration=RuleConfiguration.default) + ?(helpUri="") + ?(properties=Properties.default) + () = { id; name; shortDescription; fullDescription; messageStrings; richMessageStrings; configuration; helpUri; properties } @@ -792,9 +792,9 @@ module Resources = struct rules = [] } let create - ?(messageStrings=Additional_properties.default) - ?(rules=[]) - () + ?(messageStrings=Additional_properties.default) + ?(rules=[]) + () = { messageStrings; rules } end @@ -879,38 +879,38 @@ module Sarif_result = struct properties: (Properties.t [@default Properties.default]) }[@@deriving yojson] -let create - ?(ruleId = "") - ?(level=Result_level.notApplicable) - ?(message=Message.default) - ?(analysisTarget=FileLocation.default) - ?(locations=[]) - ?(instanceGuid="") - ?(correlationGuid="") - ?(occurrenceCount=1) - ?(partialFingerprints=Additional_properties.default) - ?(fingerprints=Additional_properties.default) - ?(stacks=[]) - ?(codeFlows=[]) - ?(graphs=[]) - ?(graphTraversals=[]) - ?(relatedLocations=[]) - ?(suppressionStates=[]) - ?(baselineState=Result_baselineState.bs_absent) - ?(attachments=[]) - ?(workItemsUris=[]) - ?(conversionProvenance=[]) - ?(fixes=[]) - ?(properties=Properties.default) - () - = - { - ruleId;level; message; analysisTarget; locations; instanceGuid; - correlationGuid; occurrenceCount; partialFingerprints; fingerprints; - stacks; codeFlows; graphs; graphTraversals; relatedLocations; - suppressionStates; baselineState; attachments; workItemsUris; - conversionProvenance; fixes; properties - } + let create + ?(ruleId = "") + ?(level=Result_level.notApplicable) + ?(message=Message.default) + ?(analysisTarget=FileLocation.default) + ?(locations=[]) + ?(instanceGuid="") + ?(correlationGuid="") + ?(occurrenceCount=1) + ?(partialFingerprints=Additional_properties.default) + ?(fingerprints=Additional_properties.default) + ?(stacks=[]) + ?(codeFlows=[]) + ?(graphs=[]) + ?(graphTraversals=[]) + ?(relatedLocations=[]) + ?(suppressionStates=[]) + ?(baselineState=Result_baselineState.bs_absent) + ?(attachments=[]) + ?(workItemsUris=[]) + ?(conversionProvenance=[]) + ?(fixes=[]) + ?(properties=Properties.default) + () + = + { + ruleId;level; message; analysisTarget; locations; instanceGuid; + correlationGuid; occurrenceCount; partialFingerprints; fingerprints; + stacks; codeFlows; graphs; graphTraversals; relatedLocations; + suppressionStates; baselineState; attachments; workItemsUris; + conversionProvenance; fixes; properties + } end module VersionControlDetails = struct @@ -965,41 +965,41 @@ module Run = struct defaultFileEncoding: (string [@default "utf-8"]); columnKind: (ColumnKind.t [@default ColumnKind.unicodeCodePoints]); properties: (Properties.t [@default Properties.default]); -} -[@@deriving yojson] - -let create - ~tool - ~invocations - ?(conversion=Conversion.default) - ?(versionControlProvenance=[]) - ?(originalUriBaseIds=Additional_properties.default) - ?(files=[]) - ?(logicalLocations=[]) - ?(graphs=[]) - ?(results=[]) - ?(resources=Resources.default) - ?(instanceGuid="") - ?(correlationGuid="") - ?(logicalId="") - ?(description=Message.default) - ?(automationLogicalId="") - ?(baselineInstanceGuid="") - ?(architecture="") - ?(richMessageMimeType="text/markdown;variant=GFM") - ?(redactionToken="") - ?(defaultFileEncoding="utf-8") - ?(columnKind=ColumnKind.unicodeCodePoints) - ?(properties=Properties.default) - () - = - { - tool; invocations; conversion; versionControlProvenance; originalUriBaseIds; - files; logicalLocations; graphs; results; resources; instanceGuid; - correlationGuid; logicalId; description; automationLogicalId; - baselineInstanceGuid; architecture; richMessageMimeType; - redactionToken; defaultFileEncoding; columnKind; properties } + [@@deriving yojson] + + let create + ~tool + ~invocations + ?(conversion=Conversion.default) + ?(versionControlProvenance=[]) + ?(originalUriBaseIds=Additional_properties.default) + ?(files=[]) + ?(logicalLocations=[]) + ?(graphs=[]) + ?(results=[]) + ?(resources=Resources.default) + ?(instanceGuid="") + ?(correlationGuid="") + ?(logicalId="") + ?(description=Message.default) + ?(automationLogicalId="") + ?(baselineInstanceGuid="") + ?(architecture="") + ?(richMessageMimeType="text/markdown;variant=GFM") + ?(redactionToken="") + ?(defaultFileEncoding="utf-8") + ?(columnKind=ColumnKind.unicodeCodePoints) + ?(properties=Properties.default) + () + = + { + tool; invocations; conversion; versionControlProvenance; originalUriBaseIds; + files; logicalLocations; graphs; results; resources; instanceGuid; + correlationGuid; logicalId; description; automationLogicalId; + baselineInstanceGuid; architecture; richMessageMimeType; + redactionToken; defaultFileEncoding; columnKind; properties + } end module Schema = struct diff --git a/src/plugins/markdown-report/sarif_gen.ml b/src/plugins/markdown-report/sarif_gen.ml index c87b44bf192fd0011fdbca4fc436990d7f937b4a..02b434d62ca0f48ce880da8408a5b3ee96f28084 100644 --- a/src/plugins/markdown-report/sarif_gen.ml +++ b/src/plugins/markdown-report/sarif_gen.ml @@ -69,8 +69,8 @@ let make_message alarm annot remark = let summary = Block [Text kind; descr] in let markdown = match remark with - | [] -> summary :: gen_remark alarm - | _ -> summary :: remark + | [] -> summary :: gen_remark alarm + | _ -> summary :: remark in let richText = String.trim (Format.asprintf "@[%a@]" Markdown.pp_elements markdown) @@ -145,10 +145,10 @@ let gen_run remarks = let user_annot_results = gen_statuses () in let rules = match user_annot_results with - | [] -> rules - | _ -> - Datatype.String.Map.add - "user-spec" "User written ACSL specification" rules + | [] -> rules + | _ -> + Datatype.String.Map.add + "user-spec" "User written ACSL specification" rules in let rules = make_rule_dictionary rules in let resources = Resources.create ~rules () in diff --git a/src/plugins/server/request.ml b/src/plugins/server/request.ml index 7c042be08492731dd25c45402eed7dc1c690b37f..69daa664bdcb49c35ed920f644f031aa65d4559a 100644 --- a/src/plugins/server/request.ml +++ b/src/plugins/server/request.ml @@ -318,8 +318,8 @@ let register_sig (type a b) (s : (a,b) signature) (process : rq -> a -> b) = let synopsis = Table { caption; header; content } in let content = [ synopsis ; Block s.details] @ - doc_input s.input @ - doc_output s.output + doc_input s.input @ + doc_output s.output in let _ = Doc.publish ~page:s.page ~name:s.name ~title content [] in Main.register s.kind s.name processor ;