Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Feb 2, 2024
2 parents 2578fdd + 13fa933 commit 33f1a4b
Show file tree
Hide file tree
Showing 87 changed files with 3,033 additions and 217 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 Ivan Kniazkov
Copyright (c) 2024 Ivan Kniazkov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--
The MIT License (MIT)
Copyright (c) 2023 Ivan Kniazkov
Copyright (c) 2024 Ivan Kniazkov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -132,9 +132,9 @@ SOFTWARE.
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.9.0</version>
<groupId>com.kniazkov</groupId>
<artifactId>json</artifactId>
<version>0.3</version>
</dependency>
<dependency>
<groupId>guru.nidi</groupId>
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/org/cqfn/astranaut/core/Action.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cqfn.astranaut.core;

/**
* A node that represents an action that can be performed on another node.
* This type of nodes is necessary for the construction of difference trees.
*
* @since 1.1.0
*/
public interface Action extends DifferenceTreeItem {
}
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/Adapter.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 Ivan Kniazkov
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/Builder.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 Ivan Kniazkov
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/ChildDescriptor.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 Ivan Kniazkov
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/ChildrenMapper.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 Ivan Kniazkov
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/Common.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 Ivan Kniazkov
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/Converter.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 Ivan Kniazkov
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/cqfn/astranaut/core/ConvertibleNode.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2023 Ivan Kniazkov
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
220 changes: 220 additions & 0 deletions src/main/java/org/cqfn/astranaut/core/Delete.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2024 Ivan Kniazkov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cqfn.astranaut.core;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Action that deletes a child element.
*
* @since 1.1.0
*/
public final class Delete implements Action {
/**
* The type.
*/
public static final Type TYPE = new DeleteType();

/**
* Child element.
*/
private final Node child;

/**
* Constructor.
* @param child A child element that will be removed.
*/
public Delete(final Node child) {
this.child = child;
}

@Override
public Node getBefore() {
return this.child;
}

@Override
public Node getAfter() {
return null;
}

@Override
public Fragment getFragment() {
return this.child.getFragment();
}

@Override
public Type getType() {
return Delete.TYPE;
}

@Override
public String getData() {
return "";
}

@Override
public int getChildCount() {
return 1;
}

@Override
public Node getChild(final int index) {
final Node node;
if (index == 0) {
node = this.child;
} else {
node = null;
}
return node;
}

/**
* Type of 'Delete' action.
*
* @since 1.1.0
*/
private static final class DeleteType implements Type {
/**
* The 'Node' string.
*/
private static final String NODE = "Node";

/**
* The 'ACTION' string.
*/
private static final String ACTION = "Action";

/**
* The 'DELETE' string.
*/
private static final String DELETE = "Delete";

/**
* The list of child descriptors.
*/
private static final List<ChildDescriptor> CHILDREN =
Collections.singletonList(
new ChildDescriptor(
DeleteType.NODE,
false
)
);

/**
* Hierarchy.
*/
private static final List<String> HIERARCHY =
Collections.unmodifiableList(
Arrays.asList(
DeleteType.DELETE,
DeleteType.ACTION
)
);

/**
* Properties.
*/
private static final Map<String, String> PROPERTIES = Stream.of(
new String[][] {
{"color", "blue"},
}).collect(Collectors.toMap(data -> data[0], data -> data[1]));

@Override
public String getName() {
return DeleteType.DELETE;
}

@Override
public List<ChildDescriptor> getChildTypes() {
return DeleteType.CHILDREN;
}

@Override
public List<String> getHierarchy() {
return DeleteType.HIERARCHY;
}

@Override
public String getProperty(final String name) {
return DeleteType.PROPERTIES.getOrDefault(name, "");
}

@Override
public Builder createBuilder() {
return null;
}
}

/**
* Class for 'Delete' action construction.
*
* @since 1.1.0
*/
public static final class Constructor implements Builder {
/**
* Child node.
*/
private Node child;

@Override
public void setFragment(final Fragment fragment) {
// do nothing
}

@Override
public boolean setData(final String str) {
return str.isEmpty();
}

@Override
public boolean setChildrenList(final List<Node> list) {
boolean result = false;
if (list.size() == 1) {
this.child = list.get(0);
result = true;
}
return result;
}

@Override
public boolean isValid() {
return this.child != null;
}

@Override
public Node createNode() {
Node node = EmptyTree.INSTANCE;
if (this.isValid()) {
node = new Delete(this.child);
}
return node;
}
}
}
Loading

1 comment on commit 33f1a4b

@0pdd
Copy link

@0pdd 0pdd commented on 33f1a4b Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to retrieve PDD puzzles from the code base and submit them to github. If you think that it's a bug on our side, please submit it to yegor256/0pdd:

set -x && set -e && set -o pipefail && cd /tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ && pdd -v -f /tmp/20240202-1996651-9puebh [1]: + set -e + set -o pipefail + cd /tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ + pdd -v -f...

Please, copy and paste this stack trace to GitHub:

UserError
set -x && set -e && set -o pipefail && cd /tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ && pdd -v -f /tmp/20240202-1996651-9puebh [1]:
+ set -e
+ set -o pipefail
+ cd /tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ
+ pdd -v -f /tmp/20240202-1996651-9puebh

My version is 0.23.2
Ruby version is 3.1.4 at x86_64-linux
Reading from root dir /tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ
/tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ/src/test/resources/json/after_delete_action.json is a binary file (618 bytes)
/tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ/src/test/resources/json/before_delete_action.json is a binary file (1009 bytes)
/tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ/src/test/resources/json/serialization_language_specified.json is a binary file (98 bytes)
/tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ/src/test/resources/json/serialization_to_file_expected.json is a binary file (208 bytes)
/tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ/src/test/resources/json/serialization_to_string_expected.txt is a binary file (63 bytes)
/tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ/src/test/resources/json/test_deserialization.json is a binary file (230 bytes)
/tmp/0pdd20240202-14-xxg6mq/Z2l0QGdpdGh1Yi5jb206Y3Fmbi9hc3RyYW5hdXQtY29yZS5naXQ/src/test/resources/json/tree_containing_delete_action.json is a binary file (1155 bytes)
Reading .github/workflows/build_and_test.yml ...
Reading .gitignore ...
Reading .rultor.yml ...
Reading CONTRIBUTING.md ...
Reading LICENSE.txt ...
Reading README.md ...
ERROR: ERROR: README.md; PDD::Error at README.md:27: TODO found, but puzzle can't be parsed, most probably because TODO is not followed by a puzzle marker, as this page explains: https://github.com/cqfn/pdd#how-to-format
If you can't understand the cause of this issue or you don't know how to fix it, please submit a GitHub issue, we will try to help you: https://github.com/cqfn/pdd/issues. This tool is still in its beta version and we will appreciate your feedback. Here is where you can find more documentation: https://github.com/cqfn/pdd/blob/master/README.md.
Exit code is 1

/app/objects/git_repo.rb:73:in `rescue in block in xml'
/app/objects/git_repo.rb:70:in `block in xml'
/app/vendor/ruby-3.1.4/lib/ruby/3.1.0/tempfile.rb:317:in `open'
/app/objects/git_repo.rb:69:in `xml'
/app/objects/puzzles.rb:41:in `deploy'
/app/objects/jobs/job.rb:38:in `proceed'
/app/objects/jobs/job_starred.rb:32:in `proceed'
/app/objects/jobs/job_recorded.rb:31:in `proceed'
/app/objects/jobs/job_emailed.rb:33:in `proceed'
/app/objects/jobs/job_commiterrors.rb:33:in `proceed'
/app/objects/jobs/job_detached.rb:48:in `exclusive'
/app/objects/jobs/job_detached.rb:36:in `block in proceed'
/app/objects/jobs/job_detached.rb:36:in `fork'
/app/objects/jobs/job_detached.rb:36:in `proceed'
/app/0pdd.rb:531:in `process_request'
/app/0pdd.rb:367:in `block in <top (required)>'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1706:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1706:in `block in compile!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1019:in `block (3 levels) in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1037:in `route_eval'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1019:in `block (2 levels) in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1068:in `block in process_route'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1066:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1066:in `process_route'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1017:in `block in route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1014:in `each'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1014:in `route!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1138:in `block in dispatch!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `invoke'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1133:in `dispatch!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:949:in `block in call!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `catch'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1109:in `invoke'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:949:in `call!'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:938:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/deflater.rb:44:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/xss_header.rb:20:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/path_traversal.rb:18:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/json_csrf.rb:28:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/base.rb:53:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/base.rb:53:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-protection-3.0.6/lib/rack/protection/frame_options.rb:33:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/logger.rb:17:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/common_logger.rb:38:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:261:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:254:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/head.rb:12:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/method_override.rb:24:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:219:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:2018:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1576:in `block in call'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1792:in `synchronize'
/app/vendor/bundle/ruby/3.1.0/gems/sinatra-3.0.6/lib/sinatra/base.rb:1576:in `call'
/app/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/handler/webrick.rb:95:in `service'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb:140:in `service'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/httpserver.rb:96:in `run'
/app/vendor/bundle/ruby/3.1.0/gems/webrick-1.8.1/lib/webrick/server.rb:310:in `block in start_thread'

Please sign in to comment.