Did you know ... Search Documentation:
Pack logtalk -- logtalk-3.99.0/tools/dead_code_scanner/SCRIPT.txt

This file is part of Logtalk https://logtalk.org/ Copyright 2016 Barry Evans <barryevans@kyndi.com> and Paulo Moura <pmoura@logtalk.org> SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

% make sure to compile any files that you want to scan for dead code with % the required source_data flag turned on:

| ?- set_logtalk_flag(source_data, on). ...

% load the tool:

| ?- logtalk_load(dead_code_scanner(loader)). ...

% run the dead_code_scanner tool unit tests:

| ?- logtalk_load(dead_code_scanner(tester)). ...

% apply the tool to itself:

| ?- dead_code_scanner::library(dead_code_scanner). ...

% load the standard library and scan it for dead code:

| ?- logtalk_load(library(all_loader)). ...

| ?- dead_code_scanner::library(library). ...

% scan a specific entity for dead code:

| ?- dead_code_scanner::entity(logtalk). ...

% get a list of all dead predicates in the built-in core_messages category:

| ?- dead_code_scanner::predicates(core_messages, DeadPredicates). ...

% enumerate, by backtracking, all dead predicates in the built-in logtalk % object:

| ?- dead_code_scanner::predicate(logtalk, DeadPredicate). ...

% get a machine-readable diagnostics summary for a specific entity scan:

| ?- dead_code_scanner::diagnostics_summary(entity(core_messages), Summary). ...

% get triage-oriented machine-readable diagnostics for a specific entity scan:

| ?- dead_code_scanner::diagnostics(entity(core_messages), Diagnostics). ...

% individual diagnostic terms include the rule id, severity, confidence, % message, context, file, lines, and properties:

| ?- dead_code_scanner::diagnostic(entity(core_messages), Diagnostic). ...

% generate a SARIF report for a specific entity scan using the standalone % SARIF tool:

| ?- logtalk_load(sarif(loader)). ...

| ?- sarif::generate(dead_code_scanner, entity(core_messages), file('report.sarif.json'), []). ...

% The generated SARIF report uses one rule descriptor per finding class and % maps confidence to triage-aware result levels. For example, local dead code % findings are exported using the local_dead_code rule and medium-confidence % results are emitted as note level, while high-confidence unused resource % findings use the unused_uses_resource or unused_use_module_resource % rules and are emitted as error level.