Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate code (part 4) #1264

Open
LucasSte opened this issue Apr 12, 2023 · 4 comments
Open

Duplicate code (part 4) #1264

LucasSte opened this issue Apr 12, 2023 · 4 comments
Labels
good first issue Good for newcomers

Comments

@LucasSte
Copy link
Contributor

LucasSte commented Apr 12, 2023

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/sema/statements.rs#L1043-L1063

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/sema/expression/function_call.rs#L1715-L1735

======================================
3.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/substrate/storage.rs#L152-L158

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L776-L783

=======================================
4.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/substrate/storage.rs#L582-L590

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/substrate/storage.rs#L760-L769

=======================================
5.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/substrate/storage.rs#L693-L703

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/substrate/storage.rs#L739-L749

========================================
6.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/codegen/storage.rs#L114-L135

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/codegen/storage.rs#L288-L309

========================================
7.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/strings.rs#L236-L246

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/strings.rs#L260-L270

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/strings.rs#L282-L292

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/strings.rs#L312-L322

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/strings.rs#L336-L346

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/strings.rs#L403-L413

========================================
8.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/abi/substrate.rs#L287-L300

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/abi/substrate.rs#L372-L384

========================================
9.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/codegen/dispatch/substrate.rs#L341-L360

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/codegen/dispatch/substrate.rs#L398-L417

========================================
10.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L100-L110

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L182-L192

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L334-L344

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L440-L450

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L548-L558

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L837-L847

========================================
11.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L354-L369

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L1019-L1034

========================================
12.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L623-L636

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L2069-L2082

========================================
13.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L876-L887

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L929-L939

========================================
14.

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L2023-L2041

https://github.com/hyperledger/solang/blob/1b46d73b32449a09ba1c1e54c8073ecb4d7cf4a0/src/emit/solana/target.rs#L2093-L2111

@ggold7046
Copy link

Hi @LucasSte , could please guide me a little bit more about how solve this problem ?

@LucasSte
Copy link
Contributor Author

LucasSte commented May 14, 2023

Hi @LucasSte , could please guide me a little bit more about how solve this problem ?

Hi @ggold7046, this issue points fourteen sections of code that are duplicate. The solution here is to remove them.

In some cases, however, the fix is not as simple as writing a function to remove the code duplication. Some parts require complete refactoring!

If you are interested in working on this issue, please read through the code to understand the problem.

@ggold7046
Copy link

Thanks @LucasSte for the info. Could you please guide which coding part could be removed by writing function ?

@LucasSte
Copy link
Contributor Author

Thanks @LucasSte for the info. Could you please guide which coding part could be removed by writing function ?

Hey @ggold7046,

The code excerpts in the issue come from a duplication detection tool my IDE has. I have just pasted them here without analyzing anything.

If you are interested in working on this issue, I suggest that you go over them yourself and understand the problems. The knowledge you can acquire by doing that will not only help you removing duplicate code from our repository but also be the base for other contributions.

Once you have made progress on that, we are happy to discuss and review your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants