Showing 97 of 98 total issues
Method findPostsByKeyword
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@Override
@Nullable
public List<DhtProto.Post> findPostsByKeyword(String keyword)
{
keyword = keyword.toLowerCase(Locale.getDefault());
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method getAllHashesByStatus
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
@WorkerThread
public List<String> getAllHashesByStatus(int status){
String[] projection = {
KnownPostsEntry.COLUMN_POST_HASH,
KnownPostsEntry.COLUMN_COMMENT_HASH};
Method findCommentsByPost
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Deprecated
@Override
@NonNull
public List<DhtProto.Comment> findCommentsByPost(String postHash)
{
Method dumpKnownPosts
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
@WorkerThread
@NonNull
public List<Pair<String, String>> dumpKnownPosts(@Nullable Date since) {
List<Pair<String, String>> hashes = new ArrayList<>();
Method getSync
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
@NonNull
public Sync.SyncMessage getSync(MeshId peer, int version) {
// get time last sent data
Sync.SyncMessage.Builder builder = Sync.SyncMessage.newBuilder();
Method findUsersByName
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
@Nullable
public List<Pair<String, DhtProto.User>> findUsersByName(String name)
{
if (name == null) {
Identical blocks of code found in 2 locations. Consider refactoring. Open
try {
if (bundle != null) {
currentUser = DhtProto.User.parseFrom(bundle.getByteArray(getString(R.string.user_object_key)));
} else if (savedInstanceState != null) {
currentUser = DhtProto.User.parseFrom(savedInstanceState.getByteArray(getString(R.string.user_object_key)));
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 82.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method upgradeV6
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
static void upgradeV6(SQLiteDatabase db){
// need to get the old values from the table
List<Pair<String, String>> knownPosts = new ArrayList<>();
Identical blocks of code found in 2 locations. Consider refactoring. Open
try {
if(bundle != null){
postObject = DhtProto.Post.parseFrom(bundle.getByteArray(getString(R.string.post_object_key)));
}
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 82.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public static final String SQL_CREATE_USERS = "CREATE TABLE " + UserEntry.TABLE_NAME +
"(" +
UserEntry._ID + " INTEGER PRIMARY KEY," +
UserEntry.COLUMN_ID + " VARCHAR(36) UNIQUE," +
UserEntry.COLUMN_FIRST_NAME + " VARCHAR," +
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 82.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method getCustomView
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private View getCustomView(int position, @Nullable View convertView, @NonNull ViewGroup parent)
{
ListState data = tagList.get(position);
ViewHolder holder;
Method onDoneClicked
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void onDoneClicked()
{
String firstName = firstNameInput.getText().toString();
String lastName = lastNameInput.getText().toString();
String email = emailAddressInput.getText().toString();
Similar blocks of code found in 2 locations. Consider refactoring. Open
static final String SQL_CREATE_SYNC_STATS = "CREATE TABLE " + SyncStatsEntry.TABLE_NAME + " (" +
SyncStatsEntry._ID + " INTEGER PRIMARY KEY," +
SyncStatsEntry.COLUMN_DATA_SEND_ID + " VARCHAR UNIQUE," +
SyncStatsEntry.COLUMN_PEER_ID + " VARCHAR," +
SyncStatsEntry.COLUMN_PACKET_SIZE + " INTEGER," +
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 82.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
@WorkerThread
public boolean unblockUser(@Size(max = 36) String userID)
{
if (userID == null) {
return false;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 80.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
@WorkerThread
public boolean unregisterForNotification(@Size(max = 36) String hash) {
if (hash == null) {
return false;
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 80.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method getTimeLastSentData
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
@WorkerThread
public Date getTimeLastSentData(String peerID) {
Date time = new Date(0);
Method getFilter
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public Filter getFilter() {
/*
* This class is the tag filter. The CharSequence must be a list of tags that are
* denominated with a ':' character.
Method onCreateView
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_signup, container, false);
Method onDoneClicked
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void onDoneClicked()
{
String oldPassword = oldPasswordInput.getText().toString();
String newPassword = newPasswordInput.getText().toString();
String newPasswordConf = newPasswordConfInput.getText().toString();
Similar blocks of code found in 2 locations. Consider refactoring. Open
personalForumsBtn.setOnClickListener(view1 -> {
Log.i(TAG, "Your forums button pressed");
FragmentDiscoverForums frag = new FragmentDiscoverForums();
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 76.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76