Skip to content

Commit

Permalink
Merge branch 'develop' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenLooman committed Feb 29, 2024
2 parents 85126f8 + 5b3197c commit 25ebc12
Show file tree
Hide file tree
Showing 24 changed files with 80 additions and 29 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/publish-checks-wiki.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Publish checks to wiki
on:
push:
branches: [develop]
paths:
- .github/workflows/publish-checks-wiki.yml
- magik-checks/src/main/resources/nl/ramsolutions/sw/sonar/l10n/magik/rules
concurrency:
group: publish-checks-wiki
cancel-in-progress: true
permissions:
contents: write
jobs:
publish-wiki:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
python3 -m pip install --upgrade pip
python3 -m pip install html2text==2024.2.25
- run: |
mkdir -p wiki/checks
for f in magik-checks/src/main/resources/nl/ramsolutions/sw/sonar/l10n/magik/rules/*.html
do
name=$(basename $f .html)
echo Generating wiki/checks/Check-$name.md
html2text -b 0 $f > wiki/checks/Check-$name.md
done
- uses: Andrew-Chen-Wang/github-wiki-action@86138cbd6328b21d759e89ab6e6dd6a139b22270
with:
path: wiki
#dry-run: true
if: ${{ github.repository_owner == 'StevenLooman' }}
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Add base functionality to apply fixes from magik-lint.

0.9.0 (unreleased)
0.9.0 (2024-02-26)

- Support configurable libs dirs.
- Read and register in which module a definition lives.
Expand Down
2 changes: 1 addition & 1 deletion magik-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>magik-checks</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion magik-debug-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>magik-debug-adapter</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions magik-language-server/client-vscode/client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion magik-language-server/client-vscode/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Magik Language Server and Debug Adapter client for VSCode",
"author": "Steven Looman",
"license": "GPL-3.0-only",
"version": "0.9.0-SNAPSHOT",
"version": "0.9.1-SNAPSHOT",
"publisher": "StevenLooman",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion magik-language-server/client-vscode/client/src/const.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const MAGIK_TOOLS_VERSION = '0.9.0-SNAPSHOT';
export const MAGIK_TOOLS_VERSION = '0.9.1-SNAPSHOT';
4 changes: 2 additions & 2 deletions magik-language-server/client-vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion magik-language-server/client-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Magik Language Server",
"author": "Steven Looman",
"license": "GPL-3.0-only",
"version": "0.9.0-SNAPSHOT",
"version": "0.9.1-SNAPSHOT",
"repository": {
"type": "git",
"url": "https://github.com/StevenLooman/magik-tools"
Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion magik-language-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>magik-language-server</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion magik-lint/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>magik-lint</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion magik-squid/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>magik-squid</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ private void handleUpperBody(final AstNode ifNode) {
// be `_unset`.
final AstNode ifStatementNode = ifNode.getFirstAncestor(MagikGrammar.STATEMENT);
final AstNode nextSiblingNode = ifStatementNode.getNextSibling();
if (nextSiblingNode == null) {
// No next sibling node, nothing to do.
return;
}

final AstNode upperBodyNode = ifStatementNode.getFirstAncestor(MagikGrammar.BODY);
final AstNode elseNode = ifNode.getFirstChild(MagikGrammar.ELSE);
final List<AstNode> conditionalExpressionNodes =
Expand Down
2 changes: 1 addition & 1 deletion magik-typed-checks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>magik-typed-checks</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import nl.ramsolutions.sw.magik.analysis.typing.types.AbstractType;
import nl.ramsolutions.sw.magik.analysis.typing.types.ExpressionResult;
import nl.ramsolutions.sw.magik.analysis.typing.types.Method;
import nl.ramsolutions.sw.magik.analysis.typing.types.UndefinedType;
import nl.ramsolutions.sw.magik.api.MagikGrammar;
import nl.ramsolutions.sw.magik.typedchecks.MagikTypedCheck;
import org.sonar.check.Rule;
Expand All @@ -23,24 +24,27 @@ public class UndefinedMethodCallResultTypedCheck extends MagikTypedCheck {
@Override
@SuppressWarnings("checkstyle:NestedIfDepth")
protected void walkPostMethodInvocation(final AstNode node) {
final MethodInvocationNodeHelper helper = new MethodInvocationNodeHelper(node);
final LocalTypeReasonerState reasonerState = this.getTypeReasonerState();
final AbstractType receiverType = this.getTypeInvokedOn(node);
if (receiverType == UndefinedType.INSTANCE) {
// Don't bother with method invocations on UNDEFINED.
return;
}

final ExpressionResult result = reasonerState.getNodeType(node);
if (result.containsUndefined()) {
final AstNode firstIdentifierNode = node.getFirstChild(MagikGrammar.IDENTIFIER);
final AstNode issueNode = firstIdentifierNode != null ? firstIdentifierNode : node;

final MethodInvocationNodeHelper helper = new MethodInvocationNodeHelper(node);
final String methodName = helper.getMethodName();

AbstractType calledType = this.getTypeInvokedOn(node);
final Collection<Method> methods = calledType.getMethods(methodName);
if (!methods.isEmpty()) {
// Set real called type.
// TODO: Only first method, or should we test all methods?
final Method method = methods.iterator().next();
calledType = method.getOwner();
}
final String fullMethodName = calledType.getFullName() + "." + methodName;
final Collection<Method> methods = receiverType.getMethods(methodName);
final String receiverFullName =
!methods.isEmpty()
? methods.iterator().next().getOwner().getFullName()
: receiverType.getFullName();
final String fullMethodName = receiverFullName + "." + methodName;

final String message = String.format(MESSAGE, fullMethodName);
this.addIssue(issueNode, message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ void testMethodInvocationDefined() {
final List<MagikIssue> issues = this.runCheck(code, definitionKeeper, check);
assertThat(issues).isEmpty();
}

@Test
void testMethodInvocationOnUndefined() {
final String code = "" + "_block\n" + " undefined.m()\n" + "_endblock";
final IDefinitionKeeper definitionKeeper = new DefinitionKeeper();
final MagikTypedCheck check = new UndefinedMethodCallResultTypedCheck();
final List<MagikIssue> issues = this.runCheck(code, definitionKeeper, check);
assertThat(issues).isEmpty();
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Magik Tools</name>
Expand Down
2 changes: 1 addition & 1 deletion sonar-magik-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>sonar-magik-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion sslr-magik-toolkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>nl.ramsolutions</groupId>
<artifactId>magik-tools</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1-SNAPSHOT</version>
</parent>

<artifactId>sslr-magik-toolkit</artifactId>
Expand Down
Empty file added wiki/.gitignore
Empty file.

0 comments on commit 25ebc12

Please sign in to comment.